Many sites of ill repute use a technique that causes the following distressing situation: When you try to leave the site, either by using the Back button or by closing the browser window, the site reappears in a new window. In the worst cases, the site pops up in three or four new windows when you try to leave it, and basically the only way out is to shut down your computer. The way most people get trapped into these sites is through listings in search engines that look legitimate until you click on them.
The way these sites work is as follows. If you have read the HowStuffWorks article How Web Pages Work, you know that the HTML code for the simplest Web pages looks like this:
Content of the page goes here...!
The tag marks the beginning of the body of the page. You are allowed to modify the body tag. For example, if you change it so it looks like , then the background color of the page will be yellow.
When the replay function gets called, you can see that all it does is open a new window that contains whatever page is requested (here, it's www.blahblahblah.com). There's nothing to stop the creator of the Web page from opening up multiple windows -- simply adding four more open lines to the replay function will cause five new windows to open. If they all do the same thing, your screen quickly fills with dozens of windows. That's when you have to shut down.
The use of the flag variable is interesting. That's there because if the page contains a link, it causes onUnload to get triggered when the link is clicked. So the link will contain the following code:
This turns off the replay function if the user clicks the link on the page.