A
Andy Haupt
Hello ,
does the 'onload' event fire only once per window?
I was trying to load a sequence of URLs into a window by accessing the
new URL in the onload handler of the current one but my code executes
only the first onload. The script simply stops after the second url is
loaded. Why?
code is as follows:
var url = new Array(
'http://www.yahoo.com',
'http://www.google.com',
'http://www.msnbc.com'
);
var attr="scrollbars=no,toolbar=no,directories=no,resizable=no,status=no,
alwaysRaised=no,width=660,height=600";
var count = 0;
// This is the first URL to be loaded
var win = window.open( url[count], 'myWindow', attr);
// this is needed to overcome the security restrictions in Netscape
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
win.enableExternalCapture();
win.captureEvents(Event.LOAD);
// this is the onload handler: it displays an alert and loads
// the new url.
// It works the first time ie. after yahoo has loaded it shows
// the alert and loads google but nothing else happens.
win.onload = function(evt) {
alert(evt.target.name + " loaded");
count++;
win.location = url[count];
return false;
}
any pointers are appreciated.
rgds
Andy
does the 'onload' event fire only once per window?
I was trying to load a sequence of URLs into a window by accessing the
new URL in the onload handler of the current one but my code executes
only the first onload. The script simply stops after the second url is
loaded. Why?
code is as follows:
var url = new Array(
'http://www.yahoo.com',
'http://www.google.com',
'http://www.msnbc.com'
);
var attr="scrollbars=no,toolbar=no,directories=no,resizable=no,status=no,
alwaysRaised=no,width=660,height=600";
var count = 0;
// This is the first URL to be loaded
var win = window.open( url[count], 'myWindow', attr);
// this is needed to overcome the security restrictions in Netscape
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
win.enableExternalCapture();
win.captureEvents(Event.LOAD);
// this is the onload handler: it displays an alert and loads
// the new url.
// It works the first time ie. after yahoo has loaded it shows
// the alert and loads google but nothing else happens.
win.onload = function(evt) {
alert(evt.target.name + " loaded");
count++;
win.location = url[count];
return false;
}
any pointers are appreciated.
rgds
Andy