Solved

insert a ns4/ie switch in a script

Posted on 2001-08-20
2
130 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

770 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