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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SOLVED - javascript image replace question from a newbie

    Hi there,
    Sorry for the really basic question. I am trying a simple image replace which is working fine in most browsers but not in Safari. I can't find why. can anyone help?

    Code:
    <a href="#" title="Test portfolio Item" onmouseover="document.image_2.src='uploads/news/id2/narrowboats-2.png';" onmouseout="document.image_2.src='uploads/news/id2/narrowboats-1.png';">
    <img src="uploads/news/id2/narrowboats-1.png" width="235" height="132" alt="Test portfolio Item" id="image_2" />
    </a>
    Last edited by graphicsgirl; 10-05-2012 at 02:49 PM. Reason: solved

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,983
    Thanks
    56
    Thanked 557 Times in 554 Posts
    I haven't tested it, but it's possible that Safari is one of the few browsers left that will not let you address elements by their bare id. If that's the case you would be looking for something like

    Code:
    onmouseover="document.getElementById('image_2').src='uploads/news/id2/narrowboats-2.png';"
    //etc
    which will work in all browsers

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That did it! Thanks!


  •  

    Posting Permissions

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