Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with Netscape text rotation

Posted on 2000-03-02
8
Medium Priority
?
183 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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 …

963 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