Help with MM_swapImgRestore()

Discussion in 'JavaScript' started by asianstyler, May 22, 2007.

  1. #1
    Hey there, so this is my first time posting here, hoping for some help. I'll get straight to it.
    I am trying to have a single image trigger the swapImgRestore() for two different images. I have the MM_swapImage for the two different images and that works perfectly fine.
    The problem is the swapImgRestore only restores the previously coded MM_swapImage.
    What I have so far looks like this:

    <img src="images/square.png" alt="" name="motion3" width="19" height="19" border="0" id="motion3"
    onMouseOver="MM_swapImage('motionbox','','images/Test1.jpg',1);MM_swapImage('motion3','','images/white.png',1)"
    onMouseOut="MM_swapImgRestore()"/>
    Code (markup):
    I do have the functions defined within the <head> tag. I tried modifying the MM_swapImgRestore but have had no luck in getting it to work, which came out looking like this . . .
    <img src="images/square.png" alt="" name="motion3" width="19" height="19" border="0" id="motion3"
    onMouseOver="MM_swapImage('motionbox','','images/Test1.jpg',1);MM_swapImage('motion3','','images/white.png',1)"
    onMouseOut="MM_swapImgRestore();MM_swapImgRestore('images/Test1.jpg','','images/white.png',1)"/>
    Code (markup):
    If anyone has messed with this command before, I'd greatly appreciate any assistance. Thanks for your time.
     
    asianstyler, May 22, 2007 IP
  2. asianstyler

    asianstyler Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    OK. I didn't exactly solve my problem, but I found a workaround that seems to work. If anyone else has a similar problem, this may help.

    I added the swapImgRestore() script under the onMouseOut and and linking to the correct files. Thus . . .
    
    <img src="images/square.png" alt="" name="motion1" width="19" height="19" border="0" id="motion1" onClick="MM_openBrWindow('images/Test1.jpg','Test1','width=500,height=500')"
    onMouseOver="MM_swapImage('motionbox','','images/Test1.jpg',1);MM_swapImage('motion1','','images/white.png',1);MM_setTextOfLayer('name','','&lt;b&gt;&lt;font size=&quot;-1&quot; face=&quot;Helvetica, Geneva, Arial, SunSans-Regular, sans-serif&quot; color=&quot;white&quot;&gt;_ACTIVELIFE&lt;/font&gt;&lt;/b&gt;');MM_setTextOfLayer('info','','&lt;b&gt;&lt;font size=&quot;-1&quot; face=&quot;Helvetica, Geneva, Arial, SunSans-Regular, sans-serif&quot; color=&quot;white&quot;&gt;\nClient: Nike&lt;br&gt;\nStudio: Nike Design Studio&lt;br&gt;\nOh, urban-motif design. How I love thee...\n&lt;/font&gt;&lt;/b&gt;')"
    onMouseOut="MM_swapImgRestore();[B]MM_swapImage('motionbox','','images/white.png',1)[/B];MM_setTextOfLayer('name','','&lt;b&gt;&lt;font size=&quot;-1&quot; face=&quot;Helvetica, Geneva, Arial, SunSans-Regular, sans-serif&quot; color=&quot;white&quot;&gt;_Name&lt;/font&gt;&lt;/b&gt;');MM_setTextOfLayer('info','','')"/>
    Code (markup):
     
    asianstyler, May 23, 2007 IP
  3. bryan2

    bryan2 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I had this problem and found this forum almost immediately. After digging further, as this site didn't have the solution, but only the work around, I discover it. You're calling on the function too many times. I was using Dreamweaver, and it automatically codes it this way.

    The solution is to condense the code thusly:
    <img src="images/square.png" alt="" name="motion3" width="19" height="19" border="0" id="motion3"
    onMouseOver="MM_swapImage('motionbox','','images/Test1.jpg','motion3','','images/white.png',1)"
    onMouseOut="MM_swapImgRestore()"/> 
    Code (markup):
     
    bryan2, Nov 24, 2009 IP