Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

insert a ns4/ie switch in a script

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

824 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