Solved

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

Posted on 2004-04-14
7
216 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
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:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

816 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

9 Experts available now in Live!

Get 1:1 Help Now