Another example of Zen Magic.
Any on_load.js file in this directory can be used to
modify the body tag with a javascript on_load()
function.
For site-wide operation, just name the file "on_load.js
" and store it in this folder. Multiple files may be present, and can be entered by adding an underscore and more letters to the filename.
For page-specific operation, put the file under the /includes/modules/pages/{pagename}/
folder.
NOTE: on_load_*.js files must contain ONLY the raw code to be inserted in the <body>
tag in the on_load=""
parameter.
The effect is like this:
<body onload="WHATEVER_YOUR_FILE_CONTAINS_GOES_HERE">
Essentially, the contents of the file will be a function call to the DOM or to functions loaded in a jscript file.
OVERRIDE Operation:
1. Checks the existence of "on_load" scripts for the individual page first
Looks in "/includes/modules/pages/{PAGENAME}/
" for files named "on_load_*.js"
2. Then checks for site-wide overrides in "includes/templates/TEMPLATE/jscript/on_load/on_load_*.js
"
document.getElementById('email_address').focus();
<body id="login" onload="document.getElementById('email_address').focus();">
includes/templates/{template_directory}/jscript/jscript_preloadimages.js
includes/templates/{template_directory}/jscript/on_load/on_load_image_preload.js
preloadImages();