Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

OnMouseOver in Netscape

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
saskia
Asked:
saskia
  • 2
  • 2
1 Solution
 
BlessyCommented:
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
 
mgfranzCommented:
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
 
BlessyCommented:
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
 
mgfranzCommented:
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
 
saskiaAuthor Commented:
keep up the good work..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now