bmgz wrote:
I need to execute a JavaScript function "onload". The only problem is I
don not have access to the <body> tag as it is a part of the standard
page-header include (a separate file). How could I have certain pages
execute my function() onLoad?
Put
window.onload = function (evt) {
yourLoadHandler();
};
in a script (preferably included in the head section).
In newer browsers you have also attach multiple event listeners e.g. for
Mozilla or other DOM Level 2 Events compliant browsers you can do
if (typeof window.addEventListener != 'undefined') {
window.addEventListener(
'load',
function (evt) {
yourLoadHandler();
},
false
);
}
and in IE 5.5 and later you can do
else if (typeof window.attachEvent != 'undefined') {
window.attachEvent(
'onload',
function () {
yourLoadHandler();
}
);
}
That way multiple independent scripts can have load handlers added.
--
Martin Honnen
http://JavaScript.FAQTs.com/