Solved

I have a function that works perfectly in IE but not in Netscape 7...can anybody help?

Posted on 2004-04-14
7
214 Views
Last Modified: 2010-04-06
Hi,

The following function works fine in IE but not in Netscape. Basically, if there is no 'Next' page a 'Close window' link appears instead of 'Next'. However in Netscape 'Next' and 'Close window' appear at the same time. Can anyone remedy this??

Note: There is no next page when curPage == "ppc6.htm" || curPage == "palmpc7.htm" || curPage == "palmmac7.htm"

The code is as follows:

var nav = new Object();
         
                                  nav["pda.htm"] = ["", ""];
              nav["palmpc1.htm"] = ["", ""];
              nav["palmpc3.htm"] = ["palmpc1.htm", "palmpc3a.htm"];
              nav["palmpc3a.htm"] = ["palmpc3.htm", "palmpc4.htm"];
                                  nav["palmpc4.htm"] = ["palmpc3a.htm", "palmpc5.htm"];
                                  nav["palmpc5.htm"] = ["palmpc4.htm", "palmpc6.htm"];
                                  nav["palmpc6.htm"] = ["palmpc5.htm", "palmpc7.htm"];
                                  nav["palmpc7.htm"] = ["palmpc6.htm", ""];
         
              nav["palmmac3.htm"] = ["palmpc1.htm", "palmmac3a.htm"];
              nav["palmmac3a.htm"] = ["palmmac3.htm", "palmmac4.htm"];
              nav["palmmac4.htm"] = ["palmmac3a.htm", "palmmac5.htm"];
                             nav["palmmac5.htm"] = ["palmmac4.htm", "palmmac6.htm"];
              nav["palmmac6.htm"] = ["palmmac5.htm", "palmmac7.htm"];
              nav["palmmac7.htm"] = ["palmmac6.htm", ""];
             
              nav["ppc1.htm"] = ["", ""];
              nav["ppc1a.htm"] = ["ppc1.htm", "ppc2.htm"];
              nav["ppc2.htm"] = ["ppc1.htm", "ppc3.htm"];
              nav["ppc3.htm"] = ["ppc2.htm", "ppc4.htm"];
              nav["ppc4.htm"] = ["ppc3.htm", "ppc5.htm"];
              nav["ppc5.htm"] = ["ppc4.htm", "ppc6.htm"];
              nav["ppc6.htm"] = ["ppc5.htm", ""];

var stoplimit = 20;
             
function checkNav()
{
               if (parent.content && parent.content.location && typeof next != "undefined" && typeof prev != "undefined")
               {
                    var curPage = parent.content.location.pathname;
                    curPage = curPage.replace(/\\/g, "/");
                    curPage = curPage.substring(curPage.lastIndexOf("/")+1);
                    next.style.visibility = (nav[curPage][1] ? "visible" : "hidden");
                    prev.style.visibility = (nav[curPage][0] ? "visible" : "hidden");
          closewin.style.display = (nav[curPage][1] ? "none" : "block");
          closewin.style.display = (curPage == "ppc6.htm" || curPage == "palmpc7.htm" || curPage == "palmmac7.htm" ? "block" : "none");
          stoplimit = 20;
               }
               else if (stoplimit)
                    setTimeout("checkNav()", 250);
               else
                    alert("error");
}
0
Comment
Question by:johnnyno
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:dorward
ID: 10822960
You appear to be depending on IE's habbit of generating global variables as referneces to elements.

I'm guessing you have something like:

<div id="closewin"> and <div id="next">

Change references from: next.something, prev.something and closewin.something to document.getElementById('next').something etc.

e.g.                     prev.style.visibility = (nav[curPage][0] ? "visible" : "hidden");

to

                    document.getElementById('prev').style.visibility = (nav[curPage][0] ? "visible" : "hidden");
0
 

Author Comment

by:johnnyno
ID: 10823180
Hi dorward

I tried as you suggested but still no joy. You were right however regarding how i referred to the respective div tags...

thanks for your input
0
 
LVL 17

Expert Comment

by:dorward
ID: 10823237
Well, Netscape doesn't recognise them as global variables, so that will help. You probably have additional IE only stuff in there.

I suggest you type "javascript:" into the address bar so that you can see what, if any, errors are generated when you tr to run the script. Knowing what they are will help me find out what the problem is.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:johnnyno
ID: 10823423
Hi dorward

I think there's a problem with the following line of script

if (parent.content && parent.content.location && typeof next != "undefined" && typeof prev != "undefined")

as this is what is alerted in the debugger
               
0
 
LVL 17

Accepted Solution

by:
dorward earned 500 total points
ID: 10823459
Try splitting it up to see what it is.

alert(parent.content)
alert(parent.content.location)
alert(typeof next)

and so one. Compare in IE and Mozilla.

It looks like you need to convert next to document.getElementById('next') and prev to document.etc.etc.etc also. (I'd do this before mucking about with alerts)
0
 

Author Comment

by:johnnyno
ID: 10823560
thanks dorward ur a star!!
0
 
LVL 17

Expert Comment

by:dorward
ID: 10823581
No problem. Good luck.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Contact Forms for Website 6 78
Snap images to the bottom of a div 5 65
 shows up in Outlook, not OWA or on phone 3 63
site launch date and last modified date 3 82
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

896 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

15 Experts available now in Live!

Get 1:1 Help Now