cfec
09-08-2003, 04:23 PM
All the external links on my site are opened in the same target with an anchor.
To give focus to this target if it already exists (like if it's the second external links my visitor clicks and he didn't close the window for the previous one), I use a cheat and open a window with an onclick and gives it the same name as the target.
I load a blank page in it with the onclick, give the new window the same name as the target for the anchor, and right after the browser searches for an already opened window with the same name as the target. This window always exists cause it is created right before with the onclick.
<a href=http://roxx.ca target=artist onclick="art44=window.open
('http://pages.globetrotter.net/seinline/blank.htm','artist');art44.focus()">
Here's the problem:
If the user presses shift in IE5 (same as ctrl in Netscape) while he clicks on the link, he gets the link in a new window and a gets a second window created by the onclick. So to prevent this, I just put in the file blank.htm:
<BODY onLoad="setTimeout(window.close, 5000)">
So if nothing else is loaded in this window within five seconds, it closes itself.
Then I found out that if I open the link in a new window by pressing shift, then give the focus to the art44 window by clicking on it before it closes itself, the window does close and a few seconds later, IE5 crashes and all opened windows are closed. It always happens. I tried the same in Netscape 7 and everything works fine.
So is it just IE5? Is it all versions of IE? And why does it crash? If I let the blank.htm window behind and don't click on it, IE doesn't crash and the window closes itself as it's supposed to. It's just if I click on it and give it focus before the 5 seconds timeout.
My visitors will most likely never encounter this bug, but I find it intriguing.
Any suggestions? I mean beside giving up the opening in the same target and just putting a _blank target... :)
here's the page where to test it:
http://membres.lycos.fr/cfecteau/seinfeld/musical/
To give focus to this target if it already exists (like if it's the second external links my visitor clicks and he didn't close the window for the previous one), I use a cheat and open a window with an onclick and gives it the same name as the target.
I load a blank page in it with the onclick, give the new window the same name as the target for the anchor, and right after the browser searches for an already opened window with the same name as the target. This window always exists cause it is created right before with the onclick.
<a href=http://roxx.ca target=artist onclick="art44=window.open
('http://pages.globetrotter.net/seinline/blank.htm','artist');art44.focus()">
Here's the problem:
If the user presses shift in IE5 (same as ctrl in Netscape) while he clicks on the link, he gets the link in a new window and a gets a second window created by the onclick. So to prevent this, I just put in the file blank.htm:
<BODY onLoad="setTimeout(window.close, 5000)">
So if nothing else is loaded in this window within five seconds, it closes itself.
Then I found out that if I open the link in a new window by pressing shift, then give the focus to the art44 window by clicking on it before it closes itself, the window does close and a few seconds later, IE5 crashes and all opened windows are closed. It always happens. I tried the same in Netscape 7 and everything works fine.
So is it just IE5? Is it all versions of IE? And why does it crash? If I let the blank.htm window behind and don't click on it, IE doesn't crash and the window closes itself as it's supposed to. It's just if I click on it and give it focus before the 5 seconds timeout.
My visitors will most likely never encounter this bug, but I find it intriguing.
Any suggestions? I mean beside giving up the opening in the same target and just putting a _blank target... :)
here's the page where to test it:
http://membres.lycos.fr/cfecteau/seinfeld/musical/