Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-04-2012, 05:23 PM   PM User | #1
graphicsgirl
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
graphicsgirl is an unknown quantity at this point
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
graphicsgirl is offline   Reply With Quote
Old 10-04-2012, 05:33 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,461
Thanks: 52
Thanked 457 Times in 455 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
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
xelawho is online now   Reply With Quote
Old 10-05-2012, 02:48 PM   PM User | #3
graphicsgirl
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
graphicsgirl is an unknown quantity at this point
That did it! Thanks!
graphicsgirl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:34 AM.


Advertisement
Log in to turn off these ads.