PDA

View Full Version : assigning two functions or more to window.onload


Borgtex
11-12-2002, 04:05 PM
Just discovered (due to a mistake with cut & paste) that you can assign more than one function to window.onload:

window.onload=window.open('http://www.google.com') & (top.location='about:blank') & alert('done')


Is it correct to use something like that? could cause any error?

kansel
11-12-2002, 04:18 PM
I've never used or even seen anything like this before. My preferred method is to assign a new function to the onload event.

window.onload = new function(){ window.open('http://www.google.com'); (top.location='about:blank'); alert('done')};

or to modify the onload attribute in the body tag

<body onload="window.open('http://www.google.com'); (top.location='about:blank'); alert('done')};">

Borgtex
11-12-2002, 04:23 PM
Errr... forget it. It actually launch the functions even if the page is loaded or not. It's only what it was: a mistake :o