Solved

OnMouseOver in Netscape

Posted on 2000-02-17
5
224 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
The viewer will learn how to count occurrences of each item in an array.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now