Closed Thread
Results 1 to 9 of 9

Thread: onmouseover not working

  1. #1
    EMDY is offline Newbie
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    onmouseover not working

    One of my onmouseover buttons is not working and I can't seem to spot the problem.

    Assistance? Thank you.


    HTML Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    loadImage1 = new Image();
    loadImage1.src = "http://www.address.com/no/hl.jpg";
    staticImage1 = new Image();
    staticImage1.src = "http://www.address.com/no/hd.jpg";
    
    loadImage2 = new Image();
    loadImage2.src = "http://www.address.com/no/fl.jpg";
    staticImage2 = new Image();
    staticImage2.src = "http://www.address.com/no/fd.jpg";
    
    loadImage3 = new Image();
    loadImage3.src = "http://www.address.com/no/ol.jpg";
    staticImage3 = new Image();
    staticImage3.src = "http://www.address.com/no/od.jpg";
    
    loadImage4 = new Image();
    loadImage4.src = "http://www.address.com/no/rl.jpg";
    staticImage4 = new Image();
    staticImage4.src = "http://www.address.com/no/rd.jpg";
    
    // End -->
    </script>
    
    
    
    <a href="http://www.address.com/no/INDEX.html" onmouseover="image1.src=loadImage1.src;" onmouseout="image1.src=staticImage1.src;">
    <img name="image1" src="http://www.address.com/no/hd.jpg" border=0></a>
    
    <a href="http://www.address.com/no/FINDIT.html" onmouseover="image2.src=loadImage2.src;" onmouseout="image2.src=staticImage2.src;">
    <img name="image2" src="http://www.address.com/noN/fd.jpg" border=0></a>
    
    <a href="http://www.address.com/no/FINDIT.html" onmouseover="image3.src=loadImage3.src;" onmouseout="image3.src=staticImage3.src;">
    <img name="image3" src="http://www.address.com/no/od.jpg" border=0></a>
    
    <a href="http://www.address.com/no/RETAIL.html" onmouseover="image4.src=loadImage4.src;" onmouseout="image4.src=staticImage4.src;">
    <img name="image4" src="http://www.address.com/noN/rd.jpg" border=0></a>
    Last edited by Vswe; 03-21-2010 at 04:00 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Sphexa is offline Newbie
    Join Date
    Mar 2010
    Posts
    21
    Rep Power
    0

    Re: onmouseover not working

    Which image is not loading?

  4. #3
    EMDY is offline Newbie
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Re: onmouseover not working

    It's image three, ol isn't working on mouse over

  5. #4
    macneato is offline Newbie
    Join Date
    Sep 2007
    Posts
    10
    Rep Power
    0

    Re: onmouseover not working

    Did you use dreamweaver to code it? I can quickly write up a function if you willing to use jquery. Will solve your problem

  6. #5
    macneato is offline Newbie
    Join Date
    Sep 2007
    Posts
    10
    Rep Power
    0

    Re: onmouseover not working

    Another quick question, why you using "noN" and "no" in specific places?

  7. #6
    EMDY is offline Newbie
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Re: onmouseover not working

    I used notepad. Could you give me a specific example? Thank you. Do you see where the problem is in the current code?

  8. #7
    macneato is offline Newbie
    Join Date
    Sep 2007
    Posts
    10
    Rep Power
    0

    Re: onmouseover not working

    Here is the script

    HTML Code:
             <script type="text/javascript">
              
                  jQuery(document).ready(function() { 
                    $("img.rollover").hover(
                     function()
                     {
                      this.src = this.src.replace("_default","_hover");
                     },
                     function()
                     {
                      this.src = this.src.replace("_hover","_default");
                     }
                    );                              
                  });
            </script>
            
            <a href="">
                <img  class="rollover" src="http://www.address.com/no/hd_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>
            <a  href="">
                <img  class="rollover" src="http://www.address.com/no/fd_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>        
            <a href="">
                <img  class="rollover" src="http://www.address.com/no/od_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>    
            <a href="">
                <img  class="rollover" src="http://www.address.com/no/rd_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>
    Let me explain. You will need the suffix "_default" and "_hover".

    default = Normal Image
    hover = Hover State

    NB Keep both states in the same folder

    Now you will be able to apply a rollover state anywhere within your site by assigning the class "rollover" to an image.

    Don't have Jquery?Download it.

  9. #8
    macneato is offline Newbie
    Join Date
    Sep 2007
    Posts
    10
    Rep Power
    0

    Re: onmouseover not working

    Here is the script

    HTML Code:
             <script type="text/javascript">
              
                  jQuery(document).ready(function() { 
                    $("img.rollover").hover(
                     function()
                     {
                      this.src = this.src.replace("_default","_hover");
                     },
                     function()
                     {
                      this.src = this.src.replace("_hover","_default");
                     }
                    );                              
                  });
            </script>
            
            <a href="#">
                <img class="rollover" src="http://www.address.com/no/hd_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>
            <a href="#">
                <img class="rollover" src="http://www.address.com/no/fd_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>        
            <a href="#">
                <img class="rollover" src="http://www.address.com/no/od_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>    
            <a href="#">
                <img class="rollover" src="http://www.address.com/no/rd_default.jpg" alt="" title="" border="0" width="100" height="30" />
            </a>
    1. Get Jquery (google)
    2. Add the suffix "_default" and "_hover" to the the image filename you would like to roll over.
    -default is normal state, hover is over state
    3. Assign the class "rollover" to the img tag.

    NB: Ensure all your images are within the same directory.
    Last edited by macneato; 04-21-2010 at 04:52 AM. Reason: superfluous code

  10. #9
    EMDY is offline Newbie
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Re: onmouseover not working

    Thank you. Solved.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Not working in FF/Chrome, working in IE
    By fedlerner in forum AJAX
    Replies: 17
    Last Post: 03-14-2011, 10:26 AM
  2. Triggering/sending false onmouseover singal?
    By 1988 in forum JavaScript and CSS
    Replies: 2
    Last Post: 02-04-2011, 06:09 AM
  3. Working on C++
    By Beeko in forum C and C++
    Replies: 12
    Last Post: 08-06-2010, 04:16 AM
  4. CSS Not Working?
    By Volux in forum JavaScript and CSS
    Replies: 3
    Last Post: 06-08-2010, 10:34 AM
  5. Buttons onMouseOver not working.
    By CommittedC0der in forum HTML Programming
    Replies: 8
    Last Post: 02-16-2010, 09:32 PM

Tags for this Thread

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