Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape frustrations ... :(

Status
Not open for further replies.

TeaAddictedGeek

Programmer
Apr 23, 1999
271
US
I'm trying to create a bit of code that will rotate some graphics and text underneath to go with it. It works BEAUTIFULLY in IE, I couldn't be prouder. In Netscape, the image rotation works, and the text just sits there and thumbs its nose at me.<br>
<br>
Worse yet, the Netscape browser appears to be having an identity crisis, and detecting the browser through the standard code isn't working, either.<br>
<br>
Please help! My code is included below. It's a combination of Javascript and DHTML, hence why I'm here, pleading and moaning for someone to help before I destroy all copies of Netscape in the known universe....<br>
<br>
<br>
function rotate() {<br>
<br>
browsername=navigator.appName;<br>
document.picform.slideshow.src = imgs[n];<br>
<br>
<br>
if (browsername==&quot;Netscape&quot;) <br>
document.layers[&quot;footer&quot;].document.write(footers[n]);<br>
<br>
else<br>
footer.innerHTML = footers[n];<br>
<br>
<br>
(n == (imgs.length - 1)) ? n = 0 : n++;<br>
window.setTimeout(&quot;rotate()&quot;, timedelay);<br>
}<br>
window.onload = rotate;<br>
// End --&gt;<br>
&lt;/script&gt;<br>
<br>
<br>
&lt;center&gt;<br>
&lt;form name=picform&gt;<br>
&lt;img name=slideshow src=&quot;../images/flower.gif&quot;&gt;&lt;br&gt;<br>
<br>
&lt;script&gt;<br>
browsername=navigator.appName;<br>
if (browsername==&quot;Netscape&quot;) <br>
<br>
document.write('&lt;layer id=&quot;footer&quot;&gt;');<br>
else<br>
document.write('&lt;p id =&quot;footer&quot;&gt;');<br>
<br>
&lt;/script&gt;<br>
A flower!<br>
&lt;script&gt;<br>
browsername=navigator.appName;<br>
if (browsername==&quot;Netscape&quot;) <br>
document.write('&lt;/layer&gt;');<br>
else<br>
document.write('&lt;/p&gt;');<br>
<br>
&lt;/script&gt;<br>
&lt;/form&gt;<br>
<br>
<br>

 
It may be that you didn't close off your code. Compare<br>
<br>
Your code:<br>
<i><br>
if (browsername==&quot;Netscape&quot;) <br>
document.layers[&quot;footer&quot;].document.write(footers[n]);<br>
</i><br>
<br>
The way it should be:<br>
<i><br>
if (browsername==&quot;Netscape&quot;) <br>
{<br>
document.layers[&quot;footer&quot;].document.write(footers[n]);<br>
}<br>
</i> <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
Still not working. See code below, it returns the same error:<br>
<br>
<br>
function rotate() {<br>
browsername=navigator.appName;<br>
<br>
<br>
document.picform.slideshow.src = imgs[n];<br>
<br>
if (navigator.appName.indexOf(&quot;Internet Explorer&quot;) != -1 )<br>
{<br>
footer.innerHTML = footers[n];<br>
}<br>
else<br>
{<br>
var myText = footers[n];<br>
document.layers[&quot;footer&quot;].document.open();<br>
document.layers[&quot;footer&quot;].document.write(myText);<br>
document.layers[&quot;footer&quot;].document.close();<br>
}<br>
<br>
(n == (imgs.length - 1)) ? n = 0 : n++;<br>
window.setTimeout(&quot;rotate()&quot;, timedelay);<br>
}<br>
window.onload = rotate;<br>
// End --&gt;<br>
&lt;/script&gt;<br>
&lt;/HEAD&gt;<br>
<br>
&lt;BODY&gt;<br>
<br>
&lt;center&gt;<br>
&lt;form name=picform&gt;<br>
&lt;img name=slideshow src=&quot;../images/flower.gif&quot;&gt;&lt;br&gt;<br>
<br>
&lt;/form&gt;<br>
&lt;div id=&quot;footer&quot;&gt;A flower!&lt;/div&gt;<br>
&lt;/center&gt;
 
Try using the <i>toLowerCase()</i> function, this seems to relieve a lot of problems for some reason, so instead of having <i>browsername=navigator.appName</i>, it would be <i>browsername=navigator.appName.toLowerCase()</i>. I don't know why this is, but it seems to work. I also just noticed that you do not put quotation marks around the you names. Netscape doesn't usually like this. I also just noticed that you reference your layer as <i>layer[&quot;footer&quot;]</i>, but all you really need is just <i>footer</i> (so instead of looking like <i>document.layer[&quot;footer&quot;]</i>, it would be <i>document.footer</i>. Get rid of the second <i>document</i> in <i>document.layers[&quot;footer&quot;].document.open()</i>. That would confuse any browser. A layer really isn't a separate document. <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
Quotation around the *what* names? Please explain.<br>
<br>
And the code for the layer would be document.footer.open() then?
 
In answer to your question about the layer, yes that's correct.<br>
<br>
Your code:<i><br>
&lt;img name=slideshow src=&quot;../images/flower.gif&quot;&gt;</i><br>
<br>
Mine:<i><br>
&lt;img name=&quot;slideshow&quot; src=&quot;../images/flower.gif&quot;&gt;</i> <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
LAYER is a browser-specific tag, an ugly invention that tries to make up for a sub-par browser when it comes to dHTML (sorry, Netscape). Netscape tried to guess as to what direction the W3C would turn considering layers and dHTML, and they guessed wrong. IE has a far better JavaScript DOM, and the fact that the two browsers have differing DOM's is the reason you need browser-specific code. The whole thing will be a mess until Netscape 5 comes and Netscape 4 is phased out (beta release is coming in under a month!).<br>
<br>
you don't need the brackets as ndogg proposed... if you only have one statement, you don't need the brackets, so that's definitely not your problem.<br>
<br>
I don't believe in the idea of creating browser-reactive HTML code... but that's just a personal thing. One quick idea, in your &quot;window.onload = rotate;&quot; statement. Is &quot;rotate&quot; a variable or a function here? If it's a function call, you forgot your parentheses. Also... just curious. Where is the object &quot;footer&quot; and the array &quot;footers&quot; coming from? I suppose the object is a reference to the paragraph id? Also... your image is outside of your &quot;footer&quot; layer/paragraph... I thought you wanted it inside?<br>
<br>
Best of luck :eek:) <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href= imotic ::</a><br>
 
D@^^n!t, everyone's got a gripe about Netscape, don't they? Just wait, in 25 days,beta-v6 based on Mozilla will be out and will be <b>fully</b> compliant with W3C's specification for HTML, CSS, XML, DOM, and JavaScript. Ooooh...I can't wait. <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top