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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace images onClick in Netscape?

Status
Not open for further replies.

Niavlys

IS-IT--Management
Jun 3, 2002
197
CA
Hi, I have the following code
Code:
function changeImage(Logo, Banner) 
{
newImage = "url(images/"+Logo+")";
document.getElementById('Logo').style.backgroundImage = newImage;
newImage = "url(images/"+Banner+")";
document.getElementById('Banner').style.backgroundImage = newImage;

}
...
<TD valign="top" align="right" bgcolor="#00209f" rowspan="2" width="175">
				<a target="login" onClick="changeImage('logoFr.gif', 'logo2Fr.gif')" href="[URL unfurl="true"]http://www.site.com">français</a>&nbsp;<FONT[/URL] color="#cccccc">|
				<a target="login" onClick="changeImage('logo.gif', 'logo2.gif')" href="[URL unfurl="true"]http://www.site.com">english</a>&nbsp;&nbsp;[/URL]	
</td>

This change images from english to french and inverse on click. Everything works find under IE 6 but it doesn't work under netscape 7.x. I don't know what's wrong!

Thanks for your help!
 
You don't appear to have anything with the id "Logo" or "Banner"... I can only assume that since you said it works fine in IE, that you haven't posted all the relevant source code for us to see. Can you do so, please? The code you've posted should work fine in NN7.1, so can only assume the error lies elsewhere in your code.

Either that, or NN7.1 doesn't like the fact that you want to do an image swap, but at the same time, you've asked it to load a new page. What a dilemma. Should it load the new page, or should it do the image swap? If it chooses to load the new page first (valid hrefs are provided), then it may well choose not to run the onclick. Maybe move the whole thing into an onclick (and alienate non-JS users), or remove the onclick altogether?

Hope this helps,
Dan
 
It works fine now, the id "logo" and "banner" was style sheets (sorry...). Instead of using style, I've put the logo and banner ID in the <td> tag and now it's ok.

Thanks !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top