Annoying script

Black&Red

Regular Member
Joined
Mar 14, 2008
Messages
450
Reaction score
252
Is it still possible to make those annoying sites which are impossible to close? If yes could someone share some tips (for personal use only).

Thanks
 
Add as many messages as you want, at the end of the loop it will start back at message1 indefinately and keep on looping forever:
Code:
<script>
var Messages = [
	"Message1",
	"Message2",
	"Message3"
	];
i=0;
while (i<Messages.length){
	alert(Messages[i]);
	i++;
	if (i == Messages.length){
		i=0;
		}
	}
</script>
 
An optimization tip (not that it matters on this case, but it 's good for big scripts)

Having Messages.length in the while test and on the loop will cause it to re-evaluate each time. So, it 's faster to do:
Code:
var len = Messages.length;
while(i<len) {
...

But even more, in this script the check in the while is unnecessary, since this would suffice:
Code:
var len = Messages.length;
while(1) { /* For ever */
    for (i=0; i < len; i++) {
        alert(Messages[i]);
    }
}

These are micro-optimizations than are needed only in large projects but it 's good to keep in mind, as it 's training to think more efficiently.
 
Add these script to <body onunload> to keep some functionality to your page. Using the scripts above with this technique will allow the user to use your site, but whenever they try to navigate away from your page (by pressing back button, clicking any external link or typing in a new URL) they will be bombarded by never ending alerts.
 
Quite a few people use chrome and after a couple of these it has the option to "Stop this website from opening any more alerts"
 
Quite a few people use chrome and after a couple of these it has the option to "Stop this website from opening any more alerts"


Same with firfox, it will show message 1, and all the other messages. After message 2 a little message underneath allows you to check the box to prevent additional dialogues and then it goes away.
 
Same with firfox, it will show message 1, and all the other messages. After message 2 a little message underneath allows you to check the box to prevent additional dialogues and then it goes away.
A possible workaround could be storing the current message that you are on in a variable and then onpageunload recall the script to start running again.
 
Back
Top