Solved

Help with Netscape text rotation

Posted on 2000-03-02
8
176 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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
 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript create file issue 4 60
Wrapper for APPs 9 76
Python - desktop use 1 32
Select case on click 3 15
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

770 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