Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript and Clicking to Change Photos

Status
Not open for further replies.

MariaC

Programmer
Jan 20, 2001
1
US
I'm having what appears to be compatibility problems with Netscape 6 and Netscape 4.6.

I'm trying to change a photo (name="girl") that is inside a layer and put another photo in its place.

I started by writing:
Code:
<p onClick=&quot;document.girl.src='hiking.jpg'&quot;>Hiker</p>
But this worked on Netscape 6 and IE but NOT on Netscape 4.7

Then I tried:
Code:
<a href=&quot;javascript:void(0)&quot; onClick=&quot;document.girl.src='hiking.jpg'&quot;>Hiker</a>
But this only worked with IE and not with any version of Netscape.

Does anybody know what I'm doing wrong?
 
MariaC,

I believe 'the other' browser requires the use of 'object.src' as the RValue to that expression, i.e.:

document.girl.src = hiker.src;

where 'hiker' is a image you previously loaded in your script, i.e.:

var hiker = new Image();
hiker.src = &quot;/images/hiker.jpg&quot;;

Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top