Solved

OnMouseOver in Netscape

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to echo 6 54
API Soap Calls 4 59
Problem to Popup 2 51
Remove right text widget from smaller screens 15 49
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 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

18 Experts available now in Live!

Get 1:1 Help Now