PDA

View Full Version : JavaScript Problem in Firefox


skimo
03-27-2005, 04:16 PM
I have several bits of text, when rolled over, display different images along with text describing each image. So each rollover changes two different areas. (http://www.biovance.com/Products.htm)

My problem is, which I recently found after switching mainly to Firefox, is that the text part doesn't work. They (image and text) both switch in IE, but in Firefox only the image shows up.

Would it just be easier to include the text in the image?

Also, what languages (JS, CSS) transfer throughout different browsers the best?

Any ideas on this would be much appreciated.

Thanks, Ben.
www.benjaminkopel.com

_Aerospace_Eng_
03-27-2005, 04:28 PM
try your script like this
<script type="text/javascript"><!--
function show(imageSrc, myText) {
document.getElementById('myImage').src = imageSrc;
document.getElementById('bensText').innerHTML=myText;
}
//--></script>
and give your image that has a name of "myImage" and id of "myImage".
and as far as javascript goes well gecko browsers like FF and Mozilla and Netscape all the other ones use getElementById() most of the time. CSS is rendered better in the gecko browsers while CSS in IE well it can give u some problems

skimo
03-27-2005, 06:59 PM
Thanks for that bit of code, but it didn't seem to do the trick. Maybe I didn't apply it correctly?..Wasn't sure if I needed to do anything besides drop the code in.

If I did, do you have any other ideas?

Could the DOCTYPE have anything to do with it? What is a good DOCTYPE to use?

Thanks for your help.

Ben.
www.benjaminkopel.com

_Aerospace_Eng_
03-27-2005, 07:11 PM
Originally posted by _Aerospace_Eng_

and give your image that has a name of "myImage" and id of "myImage".
Oh it works, but you failed to do what I've told which was give your image that had the name="myImage" an id also
<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<td align="center" width="240"><img src="HorseGirl.jpg" id="myImage" name="myImage" width="240" height="200"></td>
</tr>
and in your css change this
.van {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FFFFFF;}
to this
.van {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000;}
Doctypes rarely effect javascript, its the display of the page that doctypes effect, you are using the most appropiate one for you page, at least I think so

skimo
03-27-2005, 07:53 PM
Looks perfect now.

Love you long time.