No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Using JavaScript Libraries with Visualforce
You can include JavaScript libraries in your Visualforce pages to take advantage of
functionality provided by these libraries. The best way to include JavaScript libraries is by
creating a static resource, and then including the library by adding an <apex:includeScript> component to your page.
For example, if you are using jQuery (https://jquery.org), create a static resource
from the library called jquery, and then reference it in a page like
this:
You
can then use it in a page by adding a <script> to call
functions from the library.
1<apex:page>
2 <apex:includeScript value="{!$Resource.jquery}"/>
3</apex:page>If you’re using a JavaScript library in a Visualforce page, and that library
defines $ as a special character, you’ll need to
modify your JavaScript to override this usage. For example, with jQuery you can override the
definition of $ by using the jQuery.noConflict()
function.
1<apex:page >
2<apex:includeScript value="{!$Resource.jquery}"/>
3<html>
4<head>
5 <script>
6 jQuery.noConflict();
7
8 jQuery(document).ready(function() {
9 jQuery("a").click(function() {
10 alert("Hello world, part 2!");
11 });
12 });
13 </script>
14</head>
15...
16</apex:page>