10.
HTML Code:
<script>
window.onclick=function() {alert("you clicked!");}
</script>
9.
HTML Code:
<script>
window.onblur=self.focus;
</script>
8.
HTML Code:
<script>
window.onload=function() {
var h1=document.getElementsByTagName("h1")[0];
setInterval(function() {
h1.style.display=(h1.style.display=="block")?"none":"block";
}, 500);
}
</script>
</head>
<body>
<h1>Announcement</h1>
7.
HTML Code:
<!--[if IE]>
<script>
alert("Please switch to Firefox");
</script>
<![endif]-->
6.
HTML Code:
<!--[if !IE]><!-->
<script>
alert("Please switch to Internet Explorer");
</script>
<!--<![endif]-->
5.
HTML Code:
<script>
window.onunload=function() {
function dontLeave() {
if(confirm("Are you sure you want to leave?")) {
dontLeave();
} else {
dontLeave();
}
}
dontLeave();
}
</script>
4.
HTML Code:
<script>
window.onload=function() {
var bobble=document.getElementsByTagName("body")[0];
setInterval(function() {
bobble.style.marginTop=(bobble.style.marginTop=="40px")?"-40px":"40px";
}, 500);
}
</script>
</head>
<body>
<h1>Hey!</h1>
<p>Is there something wrong with your monitor?</p>
3.
HTML Code:
<script>
while(true) {alert("hello, visitor!");}
</script>
2.
(Paste this into the address bar): Courtesy of
veign.com
Code:
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);
And, the #1 most annoying javascript trick is (drumroll please):
Disabling right-click:
HTML Code:
<script>
var message="Best Site Security Ever!";
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
</script>