How can I add an onload function to the body tag?

CM1 does not allow you to edit the body tag of a page. A better way to approach this is to use jQuery selectors. Because of browser scripting discrepancies, the onload event does not function the same in all browsers. The jQuery .ready() method accounts for browser variations and waits for all elements to finish loading on a page before being called. Additionally, jQuery is packaged with CM1 and does not require any additional script includes.

The “document” object of a HTML page contains is a child of the window and encompasses the entire HTML document. Using the “document” selector with jQuery, you can add a .ready() function that is called after the entire page is loaded. If your current body tag is “”, the correct syntax for this in jQuery is:

$(document).ready(function() { callMyFunction(); });

The .ready() method accepts an anonymous function to call your function. This also allows you to add additional functions, should you need to have more called when the page is loaded.

For more information on jQuery or the .ready() method, see the following links: