Solved

insert a ns4/ie switch in a script

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now