Solved

OnMouseOver in Netscape

Posted on 2000-02-17
5
233 Views
Last Modified: 2013-12-25
I try to run the script below, but my Netscape Navigator somehow doesn't open the picture (It can't find the picture i quess). If I use the full path (D:\) in front of it I get the errormessage "Illegal url method 'D:'. With IE 4.0 I haven't got a problem. How can I modify the script so that NS will find the images ??
<script language="javascript">
<!--
if(document.images) {var img1=new Image(); img1.src="test2.bmp";}
-->
</script>

<a href="test" onMouseOver="if (document.images) document.img1.src='test2.bmp';" onMouseOut="if (document.images) document.img1.src='test1.bmp';">
<img src="test1.bmp" name="img1" border="0">

Also I would like to know which browsers do support this code.
0
Comment
Question by:saskia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Expert Comment

by:Blessy
ID: 2534409
saskia,

Your code is working fine in IE4 and Netscape Communicator 4.6, without any change.
I don't know which version of browser you are using. As far as I know,if the version of browser is 3 or above (IE & NS), it should work.  You can check the browser version using javascript.

Try like this,

<script language="javascript">
<!--
 
   browserName = navigator.appName;
   browserVer  = parseInt(navigator.appVersion);
      if (browserVer >= 3) version = "n3";
      else version = "n2";

      if (version == "n3")
      {
        picon = new Image();
        picon.src = "test2.bmp";
        picoff = new Image();
        picoff.src = "test1.bmp";
 
       function img_act(imgName)
       {
        if (version == "n3")
        {
         imgOn = eval(imgName + "on.src");
         document [imgName].src = imgOn;
        }
       }

       function img_inact(imgName)
       {
        if (version == "n3")
        {
         imgOff = eval(imgName + "off.src");
         document [imgName].src = imgOff;
        }
       }
      }
-->
  </SCRIPT>

  <A HREF = "test" TARGET="_top"
       onMouseover = "img_act('pic')"
       onMouseout = "img_inact('pic')">
       <IMG BORDER = 0 NAME = "pic"  SRC = "test1.bmp"></A>

If the browser version is less than 3, it will ignore the mouseover event and show only 'test1.bmp'.

Hope this helps you.
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 50 total points
ID: 2536244
I would have to guess that since you tested fine with IE4.0 you are also running a NN browser >4.0, your script is fine, except you can't use .bmp files in the code...  Use .gif, .jpg or .png only.

Here is a good JS code snippet;

<script language="javascript1.2">
<!--
if (document.images) {var img1=new Image(); img1.src="test2.gif";}
-->
</script>

<a href="test.htm" onMouseOver="if (document.images) document.img1.src ='test2.gif';" OnMouseOut="if (document.images) document.img1.src= 'test1.bmp';"><img src="test1.gif" name="img1" border="0"></a>
0
 

Expert Comment

by:Blessy
ID: 2541206
Hi Mark,Oops! Sorry, mgfranz,

I'm confused, whether you are talking about my code or saskia's code !!!

My code is working fine with .BMPs.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 2543394
Sorry, both of your code's are fine, and actually mine has a miss in it;

<a href="test.htm" onMouseOver="if (document.images) document.img1.src ='test2.gif';" OnMouseOut="if (document.images) document.img1.src= 'test1.gif';"><img src="test1.gif" name="img1" border="0"></a>

Widely accepted practice is to use .gif, .jpg and .png image files only due to browser incompatability, since .bmp files were created by MS it is to no suprise that they display fine in IE.  I guess there are some browsers, like NN early that will have trouble running .bmp as an inline, I know you can <!--include file"image.bmp"--> .bmp files.

Mark
0
 

Author Comment

by:saskia
ID: 2590783
keep up the good work..
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question