Forum Moderators: open
Think about it: the user downloads an HTML which includes, near the top, this tag:
<body onload="window.open(self.location);">
This causes a new window to open and will download the same HTML file into it. This HTML file includes this tag:
<body onload="window.open(self.location);">
This causes a new window to open and will download the same HTML file into it. This HTML file includes this tag:
<body onload.... Well, you get the idea. The process is repeated ad infinitum, new windows popping up all over the place until the system crashes.
I think you'd have to check the current window's URL with that of the window's opener if there is any. There are various problems with this: if your site has loaded into a window that was opened by a window on a different server, you will run into the JavaScript Same Origin security hobble. I suspect something like this would work:
if(opener && (opener.location && (opener.location.href!=self.location.href))) window.open(self.location);
I'm not sure, but give it a try.
Why do I test location.href and not just location? Because location is an object and will be passed by reference, not value: the expression opener.location!=self.location will always evaluate to true.