Solved

insert a ns4/ie switch in a script

Posted on 2001-08-20
2
133 Views
Last Modified: 2008-03-06
Hi

I have the following script:

var imgObj = null;
var openImg = new Image();
openImg.src="images/submenuposition_on.gif";
var closeImg = new Image();
closeImg.src="images/submenuposition_off.gif";
function PixelVposition(thelayername,imgName){
    var newImgObj = document.layers[thelayername].document.images[imgName];
     if(newImgObj){
         if(imgObj) {
              if(imgObj != newImgObj){
                   imgObj.src = closeImg.src;
                   newImgObj.src= openImg.src;
              }
         }
           else
           {
              newImgObj.src= openImg.src;      
         }
    }
    imgObj = newImgObj;      
}

It works good for ns4 but for ie I have to set the "var newImgObj" to:

var newImgObj = document.images[imgName];

instead to make it work in ie

How can I insert a "switch" in the script to set the correct variable for ie?
Also, will I get access to the image on the layer also in NS6?

Kind Regards
Joergen Astroem
0
Comment
Question by:jastroem
[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 Comments
 
LVL 12

Accepted Solution

by:
ahosang earned 50 total points
ID: 6408113
var newImgObj = (document.layers)?document.layers[thelayername].document.images[imgName]:document.images[imgName];
0
 

Author Comment

by:jastroem
ID: 6451724
thanks a lot - works just fine
I forgot to grade your answer...
Kind Regards
Joergen
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

623 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