Configuring the Java Script widget
Use Java Script widget to embed JavaScript code in your page.
JavaScript is used to enhance the functionality of your website. For
example, you can use JavaScript to validate user input.
To add a JavaScript code to your page, perform the following:
- Drag the Java Script widget on the page and click Edit button in the upper-right corner of the widget.
The Java Script window appears.
NOTE: If you add Java Script
widget in a page template the JavaScript is applied to all the pages
that use this template. If you add it on one particular page, the
JavaScript is applied only to this page.
- Add the JavaScript code in one of the following ways:
- If the JavaScript file (files with .js extension) you want to apply is already uploaded, on Link to a Java Script file (.js) tab, perform one of the following:
- In URL input field, enter the URL of an already uploaded JavaScript file.
- Click Select…button, browse the uploaded files to select the JavaScript file you want to apply, and click Done.
- For more information about uploading files, see
File management.
- If you want to add custom JavaScript code, on Write Java Script tab, enter the JavaScript code in the input field.
- In Where to include in HTML? radio button, select one of the following.
Select one of the following:
- In the head tag
The JavaScript is executed immediately when a page starts to load.
- Where the widget is dropped
The JavaScript is executed when the widget is being loaded.
- Before the closing body tag
The JavaScript is executed at the end of the page’s loading process.
For example, this option is often used to embed page tracking
code, such as Google Analytics, because if this code is executed, it
means that the user has not closed the page before the page has been
fully loaded.
- When you are finished, click Save.
The Java Script window closes and the system embeds the link to the JavaScript file or the code you have written where you have specified in Where to include in HTML radio button.