Referencing Custom JavaScript and CSS Files
Note: This section applies to classic forms. For CSS and Javascript in the Form Designer, see this section.
In addition to writing JavaScript and CSS on the CSS and JavaScript page, you can also include references to other JavaScript and CSS files. Including external JavaScript and CSS files can make it easier to maintain your code.
To reference a JavaScript file
- Enter the following code in the JavaScript section of the CSS and JavaScript page:
- Replace ScriptURL/scriptname.js with the URL of the JavaScript file.
- Replace code goes here with your code that references the external JavaScript file.
Note: Placing your code in this function ensures that it will wait for the external script to load before running.
- Click Save.
$(document).ready(function () {
$.getScript('ScriptURL/scriptname.js', function() {
//code goes here
});
});
To reference a CSS file
- Enter the following code in the JavaScript section of the CSS and JavaScript page:
- Replace server/CSSFileName.css with the URL of the CSS file.
- Click Save.
$(document).ready(function () {
$('head').append('<link rel="stylesheet" href="server/CSSFileName.css" type="text/css" />');
});