...

View Full Version : script help



awtherfrd
06-11-2007, 07:44 PM
I have wrote the following script to open a new window and close the parent window. It works great but I would like the parent window to stay open if the new window is blocked by a popup blocker.

Is there an easy way to do this?

The code I have now is as follows:




</head>

<html>
<head>
<script language=javascript>
function CloseWindow()
{
window.open('index.html','','')
window.open('','_self','');
window.close();
}
</script>
</head>

<body onload="CloseWindow()">

If your magazine does not load then click <a href="index.html">here</a> or enable pop-ups for this site.

</body>
</html>

smalldog
06-12-2007, 07:30 AM
Try this code



<script language=javascript>
function CloseWindow()
{
hwindow = window.open('index.html','','');
if (hwindow)
window.close();
}
</script>

glenngv
06-12-2007, 06:22 PM
Closing the parent window is not a good idea. Tabbed browsers are in nowadays, so all other pages opened by the user are gone if you close the window (but good thing browser asks confirmation to close the window if there are many tabs open). And the code you posted is a bug exploit. I don't know if any browser has fixed that bug but nevertheless, you should not rely on that exploit. It might work today, but not in the future.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum