Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-14
7
Medium Priority
?
226 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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 …
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

718 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