Advanced Search

Results 1 to 3 of 3

Thread: Need help for a little modification for the script of Shake image on Mouseover

  1. #1
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help for a little modification for the script of Shake image on Mouseover

    1) Title:
    Need help for a little modification for the script of Shake image on Mouseover

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamicindex4/shake.htm

    3) Describe problem:

    As I am new to Javascript.
    I want to shake an image as reference is provided for the DD script via the link above.
    1- onMouseover a Link
    2- and onMouseover another image.

    How I can make changes in the script for.

    For example,

    <a href="#" onMouseover="init('pic1');rattleimage()" onMouseout="stoprattle('pic1');top.focus()" onClick="top.focus()"> Click here </a>
    <img src="images/pic1.png" class="shakeimage" id="pic1">

    and

    <img src="images/mainpic.png" onMouseover="init('pic1');rattleimage()" onMouseout="stoprattle('pic1');top.focus()" onClick="top.focus()">
    <img src="images/pic1.png" class="shakeimage" id="pic1">

    An immediate reply with solution will appreciate.
    Kindly advise

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,708
    Thanks
    2
    Thanked 388 Times in 383 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style>
    .shakeimage{
    position:relative
    }
    </style>
    <script language="JavaScript1.2">
    
    /*
    Shake image script (onMouseover)-
     Dynamic Drive (www.dynamicdrive.com)
    For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
    */
    
    
    function shake(which,by,ms){
     shake.obj?shake.obj.style.top=shake.obj.style.left='0px':null;
     which=typeof(which)=='object'?which:document.getElementById(which);
     clearTimeout(shake.to);
     if (which){
      shake.obj=which;
      rattleimage(which,typeof(by)=='number'?by:3,0,typeof(ms)=='number'&&ms>50?ms:50);
     }
    }
    
    function rattleimage(obj,by,nu,ms){
     obj.style[nu%2==0?'left':'top']=by*(nu/2>=1?-1:1)+'px';
     nu=++nu%4;
     shake.to=setTimeout(function(){ rattleimage(obj,by,nu,ms); },ms);
    }
    
    
    </script></head>
    
    <body>
    
    <img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" class="shakeimage" onmouseover="shake(this);"  onmouseout="shake();"/></body>
    <br />
    <br />
    <a onmouseover="shake('tst',10,200);"  onmouseout="shake();">LINK</a>
    <br />
    <img id="tst" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" class="shakeimage" /></body>
    <br />
    <br />
    <img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" class="shakeimage" onmouseover="shake('tst',5,50);"  onmouseout="shake();"/></body>
    
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    WOW! This is what I really want.
    Thank you for your help

Similar Threads

  1. DOCTYPE issue with 'Shake Image' Script
    By Dyomar in forum Dynamic Drive scripts help
    Replies: 11
    Last Post: 03-16-2011, 05:37 PM
  2. shake image script won't get her shake on
    By moscarda in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 01-31-2009, 11:56 AM
  3. Simple script to shake gif or jpg image
    By contracer11 in forum Looking for such a script or service
    Replies: 1
    Last Post: 02-21-2008, 02:50 AM
  4. Shake Image Script
    By conewar in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 06-18-2007, 05:14 PM
  5. Shake script issue
    By Kooka in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 11-09-2004, 01:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •