Solved

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

Posted on 2004-04-14
7
212 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

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

16 Experts available now in Live!

Get 1:1 Help Now