...

View Full Version : Javascript/layer problem in Netscape



OO7girl
07-08-2004, 08:30 PM
Hi guys,

I have a script that is working fine in everything but NS 4.79, and unfortunately I NEED it to work in that browser. Currently, the script displays an XML file (styled to look pretty via an external stylesheet) in an iframe if the viewer uses IE, and in a layer if the viewer uses NS. The XML file displayed is the one corresponding to the current day of the year (e.g. July 8th).

Now, all is working fine, except for the fact that in NS 4.79, I get a popup dialog box that says "Alert! Did not find a converter or decoder". I found an article that suggested NS 4.x has trouble when certain content is "blocked," and technically the script is blocking the content that is supposed to be displayed in an iframe from being displayed as such...if that makes sense. After messing around with the code a bit, I managed to get rid of the "alert," but am left with numerous Javascript errors. There are no problems with this in Netscape 7.0 or IE.

At this point, I want to try a different approach. What I'd like to do is to have the XML file pop up in a new window when an NS user arrives at my page. Unfortunately, I am not a JS programmer (although I'm trying my darndest to be), so I'm not sure what I would need to do to the below code to make that happen. Any suggestions? Thanks!

In the head:

<script type="text/javascript">

function loadRss(){
var curDate=new Date();
var dateString=curDate.getMonth()+1+"-"+curDate.getDate()
var path=dateString+"-e"+".xml";
var targetFrame=null;

if(document.layers){
targetframe=document.layers.rssFrame;
}else if(document.getElementById){
targetFrame=document.getElementById("rssFrame");
}

targetFrame.src=path;
}
</script>



In the body:
<body onload="loadRss()">


Further down in the body:

<layer src="" style="position:absolute" top="50" left="500" width="400" height="500" name="rssFrame"><iframe src="" id="rssFrame" name="rssFrame" frameborder="0" scrolling="no"width="400px" height="500px"></layer>

Willy Duitt
07-08-2004, 09:14 PM
Both your iframe and your layer share the same name which could cause a conflict. And did you miss Glenn's ilayer reference in this thread (http://www.codingforums.com/showthread.php?p=210658#post210658), and did it not provide the solution to a simular problem?

......Willy

Edit: an example:



<html>
<head>
<title>Test Description</title>
<meta name="description" value="This is the meta-tag!" />

<script language="javascript" type="text/javascript">
<!--
function testDescription()
{
var txt = document.getElementById("description");
if (!txt)
{
alert("Not found!");
return false;
}
else
{
alert(txt.value);
}
}
//-->
</script>
</head>
<body>
<textarea id="description">This is the text area</textarea><br />
<button onclick="testDescription();">Test</button>
</body>
</html>


In most browsers, the message will display: "This is the text area". In Internet Explorer, it will display, "This is the meta-tag!".

Vincent Puglia
07-09-2004, 04:41 AM
Hi Willy :D


iframe and your layer share the same name which could cause a conflict

nope. every browser wears blinders; they see only what they want to (understand).

Vinny

OO7girl
07-09-2004, 03:26 PM
Hi Willy,

Yes, Glenn's suggestion was a great help a couple of weeks back. There have been new developments in this project since then, however, and I'm so confused after changing the code for this page so many times that I barely remember what's what anymore! :confused:

The current page I'm working on is located here:
http://www25.brinkster.com/oo7girl/vimy/glennycodingforums.html

I still can't seem to get it to work, only this time in ANY browser. Can anyone see a problem with my JS that is preventing today's file (7-9-e.xml) from being loaded automatically by Glenn's script?

Thanks!

Vincent Puglia
07-09-2004, 03:41 PM
Hi 007,

Wild guess, but perhaps because there is no setILayer:

onclick="return setILayer(this)"
function insertSrc()
{

:D
Vinny

OO7girl
07-09-2004, 03:47 PM
Hi Vinny,

do you mean that I should put that into every link I have? How would I combine that with the existing

onclick="return setILayer(this)"


, and how would that affect the automatically-loading XML document being displayed when a visitor arrives at the page?

Thanks!

jbot
07-09-2004, 03:52 PM
<layer src="" style="position:absolute" top="50" left="500" width="400" height="500" name="rssFrame"><iframe src="" id="rssFrame" name="rssFrame" frameborder="0" scrolling="no"width="400px" height="500px"></layer>



Both your iframe and your layer share the same name which could cause a conflict


NN4.x doesn't support iframes, and no other browser supports layers (yes, proper layers, not divs), so the fact that it's the same name in both shouldn't matter since browsers will only see one or the other. so, don't worry about that. :thumbsup:




Now, all is working fine, except for the fact that in NS 4.79, I get a popup dialog box that says "Alert! Did not find a converter or decoder". I found an article that suggested NS 4.x has trouble when certain content is "blocked," and technically the script is blocking the content that is supposed to be displayed in an iframe from being displayed as such...if that makes sense. After messing around with the code a bit, I managed to get rid of the "alert," but am left with numerous Javascript errors. There are no problems with this in Netscape 7.0 or IE.


i could be wrong on this, but as far as i'm aware NN4.x doesn't support XML, hence the error message, "Alert! Did not find a converter or decoder". since it has no internal XML engine, how can it convert your XML document into HTML. This won't be a problem in modern browsers because they have internal XML support, unlike Navigator. :o

anyhow, outta curiosity, how come you have to support NN4.79? (didn't think NN when any higher than 4.78, as it happens) :confused:

jbot
07-09-2004, 03:58 PM
from: http://www.w3schools.com/browsers/browsers_netscape.asp


Netscape's 4.x series of browsers have a poor support for CSS and no support for XML.

OO7girl
07-09-2004, 04:05 PM
Well, I guess that about settles it, sadly. Thanks for all your help, but I guess I'm going to have to use a redirect for Netscape 4.79 users and take them to an HTML version of "Today in History" or something similar.

Currently I'm working on using an RSS-to HTML converter (all my XML files are RSS-validated, and will also be used in an RSS feed) to display the info for NS 4.79 users. Unfortunately, I keep getting a Runtime error when I attempt to view it. Argh!

And JBot: I have to support NS 4.79 because we have a webmaster here who is very stuck in his ways and absolutely insists on it - there's no other good reason. :mad:

jbot
07-09-2004, 04:16 PM
And JBot: I have to support NS 4.79 because we have a webmaster here who is very stuck in his ways and absolutely insists on it - there's no other good reason. :mad:

kick his a** for me. :thumbsup:

i used to have a publishing manager who was like that. he insisted that we had to support NN4.08 and above because that's what they said they'd support in 1998, even tho that was 4 years later and newer and better browsers had come out since then. worse than that, every website had to look identical in each browser, even tho browser's don't work like that.

all that despite the fact none of out users were using it, never mind NS6+. funny thing was, as soon i left, the criteria changed. i'm sure he had it in for me. :rolleyes:

in the words of British comedy legend Frankie Howard, "Infamy Infamy, they've
all got it infamy!" if only that was true for some webmasters too, eh!
:D

Vincent Puglia
07-09-2004, 04:18 PM
Hi 007,


do you mean that I should put that into every link I have? How would I combine that with the existing

I meant you are calling a function that doesn't exist. The event handler call and the function name don't match -- so I would change the function name.

I didn't think NN4 supported XML (nn4 is ages old; xml is relatively new), but I figured you knew better since you were trying it.

Vinny

OO7girl
07-09-2004, 04:24 PM
Ugh - so true...it's a bit much really. The number of outdated rules and specifications we're working under here are ridiculous!

A few examples:
- all HTML tags must be in upper case
- No line of code may be longer than 75 characters

etc etc

Sheesh!

OO7girl
07-09-2004, 04:27 PM
Vinny:

No, I totally forgot that NS 4 doesn't support XML. Unfortunately, a rather time-costly memory lapse!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum