Solved

Help with Netscape text rotation

Posted on 2000-03-02
8
179 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML Anchor Link Problem 3 52
Copying table data to one another 15 37
Opening a new tab in IE using Powershell / HTML 2 45
output in HTML in Powershell 5 23
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.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

749 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