Click here to move this browser window to the left
Click here to move this browser window to the right
Click here to shake this browser window
(It's best to try the demo
on non-maximized browser window.)
The window shaking effect can be easily accomplished by using
y) function. moveBy() is a window method. It takes
two parameters, which are the x and y displacement from the current
The trick to make the window shaking is to alternate the direction of x or y or both. The
unit value for x and y are the number of pixels.
Put this code nested inside the <HEAD> tag.
<!-- var qDuration=600;
// the horizontal displacement
// make sure the browser support the moveBy method
for (qCounter=0; qCounter<qDuration; qCounter++)
// shake left
// shake right
else if ((qCounter%4)==2)
// speed up or slow down every X cycles
// speed up halfway
// slow down after halfway of the duration
To make the browser window shake immediately after the document is loaded, have "quake()"
function called in the BODY's "onLoad" method like below:
Other than for being "cool," I can't find much
good reason to shake the browser window. Use sparingly, shaking the browser
window can annoy visitors. (I have only found one really good application
of screen shake on the net; it's at the flashchallenge.com
If the code is nested inside a table, then
ugly error message like below:
to do this. For me, I like to check whether moveBy is defined or not by
explicit testing like below:
Avoid "extended hourglass"
bug. This is a "feature" that I notice in certain browser.
into the hourglass, and won't change back into the pointer, until the user moves
the mouse. This can be avoided by having "onClick" method always
For example, I prefer to use:
<A HREF="#" onClick="quake()">
Note: myVoid() is a dummy function that does nothing,
(C)2000 F. Permadi