Solved

Help with Netscape text rotation

Posted on 2000-03-02
8
171 Views
Last Modified: 2011-09-20
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.

Please help! My code is included below.

<script>

function rotate() {

browsername=navigator.appName;
document.picform.slideshow.src = imgs[n];


if (browsername=="Netscape")
document.layers["footer"].document.write(footers[n]);

else
footer.innerHTML = footers[n];


(n == (imgs.length - 1)) ? n = 0 : n++;
window.setTimeout("rotate()", timedelay);
}
window.onload = rotate;
// End -->
</script>


<center>
<form name=picform>
<img name=slideshow src="../images/flower.gif"><br>

<script>
browsername=navigator.appName;
if (browsername=="Netscape")

document.write('<layer id="footer">');
else
document.write('<p id ="footer">');

</script>
A flower!
<script>
browsername=navigator.appName;
if (browsername=="Netscape")
document.write('</layer>');
else
document.write('</p>');

</script>
</form>
0
Comment
Question by:Kyrene
  • 5
  • 3
8 Comments
 

Author Comment

by:Kyrene
ID: 2577928
Adjusted points to 100
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2578596
Try adding a document.open and document.close for the netscape script:

if (browsername=="Netscape")
{  document.layers["footer"].document.open();
 document.layers["footer"].document.write(footers[n]);
 document.layers["footer"].document.close();
}

Oh, and you should use if (document.layers) and if (document.all) instead of checking browser names.  This way you are checking to see if the functionality you require is available not a specific browser.  It's more friendly scripting:)

If this doesn't work, write back, and I'll look into it deeper.

-Josh
0
 

Author Comment

by:Kyrene
ID: 2580172
Doesn't work.  My completed code is below, still gives me that error:



function rotate() {
      browsername=navigator.appName;
      
      
      document.picform.slideshow.src = imgs[n];
      
      if (navigator.appName.indexOf("Internet Explorer") != -1 )
      {
            footer.innerHTML = footers[n];
      }
      else
      {
            var myText = footers[n];
            document.layers["footer"].document.open();
            document.layers["footer"].document.write(myText);
            document.layers["footer"].document.close();
      }

      (n == (imgs.length - 1)) ? n = 0 : n++;
      window.setTimeout("rotate()", timedelay);
}
window.onload = rotate;
//  End -->
</script>
</HEAD>

<BODY>

<center>
      <form name=picform>
            <img name=slideshow src="../images/flower.gif"><br>
            
      </form>
      <div id="footer">A flower!</div>
</center>
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2580252
Ahhh...  I can't believe I missed this before.  You have to specify absolute coordinates for the div in Netscape for it to consider it a layer.  Like this:

<DIV id="footer" style="position:absolute;top:20;left:20;">
A Flower!</DIV>

I know this is annoying because now it doesn't flow nicely with your document, but it's required for netscape to work with a div.  Now you can try using:
<ILAYER id="footer">A Flower!</ILAYER>
but that is Netscape specific.  you'd have to go back to checking for browser before writing out the code.  The nice thing about ilayers is that they are in line, and flow with the document.

If Ilayer doesn't work for you, I'm sure that the div with absolute coordinates will.
-Josh
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Kyrene
ID: 2587934
Tried both suggestions and it still gives me the same error.  It's downright weird.

Here's the code with the Iframe usage:


function rotate() {
      browsername=navigator.appName;
      
      
      document.picform.slideshow.src = imgs[n];
      
      if (navigator.appName.indexOf("Internet Explorer") != -1 )
      {
            footer.innerHTML = footers[n];
      }
      else
      {
            var myText = footers[n];
            document.layer.document.footer.document.open();
            document.layer.document.footer.document.write(myText);
            document.layer.document.footer.document.close();
      }

      (n == (imgs.length - 1)) ? n = 0 : n++;
      window.setTimeout("rotate()", timedelay);
}
window.onload = rotate;
//  End -->
</script>
</HEAD>

<BODY>

<center>
      <form name=picform>
            <img name=slideshow src="../images/flower.gif"><br>
            
      </form>
      <script>
      <!--
            browsername=navigator.appName;
            
            if (navigator.appName.indexOf("Internet Explorer") != -1 )
            {
                  document.write('<div id="footer">');
            }
            else
            {
                  document.write('<ILAYER id="footer"><center>');
            }
      //-->
      </script>
      A flower!
      <Script>
      <!--
            browsername=navigator.appName;
                        
            if (navigator.appName.indexOf("Internet Explorer") != -1 )
            {
                  document.write('</div>');
            }
            else
            {
                  document.write('</center></ILAYER> ');
            }
      //-->
      </script>
0
 

Author Comment

by:Kyrene
ID: 2587982
Adjusted points to 125
0
 
LVL 8

Accepted Solution

by:
jbirk earned 125 total points
ID: 2588421
You don't have top reject the answer if it's not solved yet.  You can still comment with out accepting or rejecting.
Anyway, unless you are in frames, the code for writing the html for netscape should be:

document.layers.footer.document.open();
document.layers.footer.document.write(myText);
document.layers.footer.document.close();

I checked it out though, and it appears that netscape won't do the dynamic writing on an ilayer either...  it needs to be a div with absolute positioning.  Sorry...  It can be a pain to get it placed where you want it, I know!  But it looks like the only solution.

-Josh
0
 

Author Comment

by:Kyrene
ID: 2588471
Thanks!!  Didn't know about the answer thing, I'm still new.  My bad.

It finally works, all I have to do is figure out how to center the div (I think use an align tag) and I'm set.

THANKS!!!!  
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

706 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

20 Experts available now in Live!

Get 1:1 Help Now