admin管理员组

文章数量:1318563

Is it possible to use Javascript to shake Firefox browser?
I find a script that works on Safari but that script doesn't seem to work on Firefox.

Thanks,
Tee

Is it possible to use Javascript to shake Firefox browser?
I find a script that works on Safari but that script doesn't seem to work on Firefox. http://www.jhuskisson./javascript/earthquake-effect-shake-the-browser

Thanks,
Tee

Share Improve this question asked Feb 24, 2011 at 0:42 teepusinkteepusink 28.9k37 gold badges108 silver badges147 bronze badges 4
  • 11 AFAIK, that is no longer possible in modern browsers. And thank goodness for that :) – Pekka Commented Feb 24, 2011 at 0:43
  • @Pekka: Though it could be more interesting again for modern browser games... "special effects" :D – Felix Kling Commented Feb 24, 2011 at 0:53
  • Unfortunately--once allowed via NoScript--the script example posted does work. – JYelton Commented Feb 24, 2011 at 1:40
  • I think by default the option in Firefox to "move or resize existing windows" is NOT enabled? So the script might work, but Firefox might be stopping it. – Jeff Commented Feb 24, 2011 at 1:43
Add a ment  | 

1 Answer 1

Reset to default 8

Because I use NoScript, this code would not execute unless I allowed it on my browser. But be warned, if you shake my browser window, I will probably blacklist your site and send flying monkeys to devour your soul.

Here is an implementation that works...use with caution:

<html>
    <head>
        <script language="javaScript">
            function shakescreen(n)
            {
                if (parent.moveBy)
                {
                    for (i = 10; i > 0; i--)
                    {
                        for (j = n; j > 0; j--)
                        {
                            parent.moveBy(0, i);
                            parent.moveBy(i, 0);
                            parent.moveBy(0, -i);
                            parent.moveBy(-i, 0);
                        }
                    }
                }
            }
        </script>
    </head>
    <body>
        <form>
            <input type="button" onClick="shakescreen(4)" value="Shake Browser Window">
        </form>
    </body>
</html>

本文标签: Javascript browser shake on FirefoxStack Overflow