0

How do I make the effect of shaking the browser screen by javascript?

On googling, I found codes involving window.moveBy(x,y) which don't seem to work. I tried them.

Any library or piece of code which would help me implement this kind of effect/animation?

gopi1410
  • 6,567
  • 9
  • 41
  • 75
  • set the document body positioning to `relative/absolute` and modify `left/top/right/bottom` I guess – Esailija May 29 '12 at 19:53
  • See this previous StackOverflow question here: http://stackoverflow.com/questions/5099141/javascript-browser-shake-on-firefox/5099453 – Random Human May 29 '12 at 19:53
  • @RandomHuman: the above example uses moveBy() which does not seem to work on my browser (maybe as Mathletics said, it is disabled in modern browsers) – gopi1410 May 29 '12 at 19:56
  • moveBy is disabled, though of course many users don't hAve a – Rich Bradshaw May 29 '12 at 19:59

1 Answers1

4

You likely won't be able to move the actual browser window as that functionality is blocked in modern browsers. However, you can "shake" the contents of the window by animating the body left/right/up/down relative to the window.

Evan Davis
  • 35,493
  • 6
  • 50
  • 57