1. Earthquake Effect: Shake the browser using JavaScript

    Note: This post was imported from the very old Twod.co.uk post archives. Please for the love of jeebus don’t use this script. Back in 2004 as a youngster this was fairly funny.

    Update: An updated and (actually) working version has been posted on StackOverflow

    This snippet of code will produce a JavaScript function which you can then attach via a JavaScript call and shake the user’s Internet browser.

    Place this anywhere before you’re going to call the function, or remove the surrounding <script> tags and place it within an external JavaScript file.

    <script type=”text/javascript”>
    function shake(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>

    An example of this function being called using the onclick method would look as follows:

    <input type=”button” onclick=”javascript:shake(200)” value=”Shake Me!” />

    This will produce (go ahead, click for an example of the effect):

    1 Comment »