Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Onmouseover - Quick Question

    My Javascript/CSS skills are somewhat limited so il just ask a quick question, iw worked out the code below but for some reason it dosnt work and i need it solved asap, reason im using Javascript for this is simply because i have to show diff technologies on the page.

    Code:
    <A HREF="index.html" onmouseover="document.images[0].src='../Images/hovedside_menu1.jpg'; return true;" onmouseout="document.images.src='../Images/hovedside_menu[0].jpg'; return true;"><IMG SRC="../Images/hovedside_menu.jpg" border="0" width="65"></A> 
    </p>
    <p>
    <A HREF="selskapet.html" onmouseover="document.images[1].src='../Images/selskapet_menu1.jpg'; return true;" onmouseout="document.images[1].src='../Images/selskapet_menu.jpg'; return true;"><IMG SRC="../Images/selskapet_menu.jpg" border="0" width="65"></A> 
          </p>
    <p>
    <A HREF="tjenester.html" onmouseover="document.images[2].src='../Images/tjenester_menu1.jpg'; return true;" onmouseout="document.images[2].src='../Images/tjenester_menu.jpg'; return true;"><IMG SRC="../Images/tjenester_menu.jpg" border="0" width="65"></A> 
          </p><p>
    <A HREF="produkter.html" onmouseover="document.images[3].src='../Images/Produkter_menu1.jpg'; return true;" onmouseout="document.images[3].src='../Images/Produkter_menu.jpg'; return true;"><IMG SRC="../Images/Produkter_menu.jpg" border="0" width="65"></A> 
          </p><p>
    <A HREF="kontakt.html" onmouseover="document.images[4].src='../Images/kontakt_menu1.jpg'; return true;" onmouseout="document.images[4].src='../Images/kontakt_menu.jpg'; return true;"><IMG SRC="../Images/kontakt_menu.jpg" border="0" width="65"></A> 
          </p>

    Sorry about the messy code, hope anyone have a solution or a "quick fix" I think it has something to do with the ["number"] bracets but im not sure how to fix this
    Thanks.
    Last edited by liorean; 06-08-2004 at 10:32 AM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    The first link should be:

    Code:
    <A HREF="index.html" onmouseover="document.images[0].src='../Images/hovedside_menu1.jpg'; return true;" onmouseout="document.images[0].src='../Images/hovedside_menu.jpg'; return true;"><IMG SRC="../Images/hovedside_menu.jpg" border="0" width="65"></A>
    
    But your implementation could be made more efficient by not relying on the index position of the image collection. The current solution will fail if you insert an image before the links. But this will not:
    
    <p>
    <A HREF="index.html" onmouseover="this.firstChild.src='../Images/hovedside_menu1.jpg'; return true;" onmouseout="this.firstChild.src='../Images/hovedside_menu.jpg'; return true;"><IMG SRC="../Images/hovedside_menu.jpg" border="0" width="65"></A> 
    </p>
    <p>
    <A HREF="selskapet.html" onmouseover="this.firstChild.src='../Images/selskapet_menu1.jpg'; return true;" onmouseout="this.firstChild.src='../Images/selskapet_menu.jpg'; return true;"><IMG SRC="../Images/selskapet_menu.jpg" border="0" width="65"></A> 
    </p>
    ...


  •  

    Posting Permissions

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