Solved

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

Posted on 2004-04-14
7
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MVC and Angular 2 123
Element alignment and word wrapping 9 80
Re-position the objects 7 124
.php tree directory? 5 89
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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:
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)

740 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