Two Hoots Banner



Javascript to Shake the Browser Window
This little fun script is used to 'shake' the browser window. It does this by using the window.moveBy function which moves the window a number of pixels right and down. Using -ve numbers you can move the window left and up.

// Function - Shake()
// Description - shake the screen
function shake(n) {
 for (i = 10; i > 0; i--) {
  for (j = n; j > 0; j--) {
  // Shake the window
  // Moveby (x,y) where x = number of pixels to move the window to the right
  // and y is the number of pixels to move the window down
  self.moveBy(0,i);
  self.moveBy(i,0);
  self.moveBy(0,-i);
  self.moveBy(-i,0);
  }
 }
}
shake screen