Ultra fast cheap  linux and windows hosting
javascript tutorial Browse Basic JavaScript Tutorial
Browse JavaScript Script resources
Browse javascript FAQS

javascript tutorial
buy template
Home >> Tutorials >> Advanced javascript tutorials

Javascript - Shaking the window

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 window

Put 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--) {

Write the following in <body> </body>.This code uses recursion to call the javascript funtion shakeWindow 10 times.

<a href=" " onmouseover="shakeWindow(10)"> shake the window</a>

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.
javascript tutorial
javascript book
Buy this book