llprogrammer
Programmer
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
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