Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.onload event is not fired?

Status
Not open for further replies.

llprogrammer

Programmer
Mar 26, 2009
13
RU
Hi all,
I'm a beginner in JavaScript and can not figure out why my code is not executed.

I have the following JS code (in my Google Chrome plugin):
if (window.top.onload) {
var existingOnload = null;
existingOnload = window.top.onload;
window.top.onload = function (ev) {// never get here
if (existingOnload) { existingOnload(ev); }
setTimeout( Plugin.init , 1);
};
} else {
Plugin.init();
}

On some sites (e.g. execution hits if (window.top.onload) {...} branch, but function
window.top.onload = function (ev) {// never get here
if (existingOnload) { existingOnload(ev); }
setTimeout( Plugin.init , 1);
};
isn't executed nevertheless! Why? Event window.top.onload is not fired?

There's following code on :
window.onload=YAHOO.Maps.loaded; ...
This code should be executed and after that main. Nevertheless execution flow doesn't get into my function window.top.onload = function (ev) {...}

The "if (window.top.onload) {...}" branch was added because of in some sites javascript in window.onload performs actions like this:
objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++)
{
objects.outerHTML = objects.outerHTML;
}
My goal is to guarantee that this code will be completely executed BEFORE my Plugin.init() invocation.

Thanks in advance!

Environment:
Windows XP SP3
Google Chrome 4.0.249.30
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top