- Print
- DarkLight
Custom Java Script files
The chapter explains how you include Java scripts that are not included in core.
To include Java Scripts in the portal that are not part of the core, there are two files that may be altered. One for the login page, ca_login_custom_scripts.vm, and one for the rest of the portal, ca_main_custom_scripts.vm. These files should be found in the project folder at the following path : /PrivateRoot/templates/vm/navigations/html/. If not, grap a copy from the net.comactivity.jetspeed project at the same path.
We recommend that any customer scripts are added in the project at the path /PublicRoot/scripts/projectName/.
Add following code to include the script:
<script type="text/JavaScript" src="scripts/projectName/fileName.js"></script>
Custom inline Java Script code
Sometimes a piece of Java Script code has to execute before the page is rendered or during rendering. In the portal there are different ways of making this happen.
If the Java Script code is specific for one portlet and there’s a custom segment, the inline Java Script code can be added to the custom segments XSL template.
If the code should always be executed, use the same files for including scripts. The ca_login_custom_scripts.vm for the login page and the ca_main_custom_scripts.vm for the rest of the portal.
To add script functions to be executed at the document.onload event, add a inline script that runs the following code :
<script type="text/javascript">
addInit( “someFunction(someParameters…)" );
addInit( “someOtherFunction()" );
</script>