Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

insert a ns4/ie switch in a script

Posted on 2001-08-20
2
Medium Priority
?
136 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

721 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