Solved

OnMouseOver in Netscape

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
paypal ipn url 5 79
"Go Fund Me" type plugin 5 24
Scroll 5 news at a time. 4 33
Finding the file/plugin that inserted my Google Analytics code? 7 33
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

860 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