Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with Netscape text rotation

Posted on 2000-03-02
8
Medium Priority
?
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 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