Home >> Tutorials >> Advanced javascript tutorials
Using JavaScript you can easily accomplish the window shaking effect. The movement is done through javascript:window.moveBy(x, y) function. moveBy() is a window method. It takes two parameters, which are the x and y displacement from the current window position.

For example, when you pass the mouse over the following link this page will shake. Shake the windowPut the following piece of javascript between <head> </head>script language=”JavaScript”> 
function shakeWindow(n) 

var i,j; 
if(top.moveBy) { 
for(i=10; i>0; i–) 
for(j=n; j>0; j–) { 

</script>Write the following in <body> </body>.This code uses recursion to call the javascript funtion shakeWindow 10 times.<body>
<a href=” ” onmouseover=”shakeWindow(10)”> shake the window</a>
<body>Draw backs
The shaking the browser window can annoy visitors.Not all browsers support the JavaScript “moveBy” method (older browsers such as Netscape 3 don’t). In that case, the browser might display ugly error message

Page contents: itechies.net – Learn how to create window shaking effect using javascript.