Set user defined code to execute on page load
Q:
How to set user defined code to execute on page unload in an AJAXPage?
A:
To execute user defined code on page load, the following JS code needs to be added in the page:
// add load event function addLoadEvent(func) {
var oldload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldload) { oldload(); } func(); } } }
The addLoadEvent method should be called with the function that needs to be executed on page load as the parameter.
For example, if myLoad method is needed to be executed on page load, the definition will be as follows:
function myLoad() { // user defined codes to be executed on page load }
addLoadEvent(myLoad);
|