spacer
Yehuda Shiran February 14, 2000
Creating A Banner
Tips: February 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

Creating a banner in Netscape Navigator is very tricky. We have already showed in our tip from January 30, 2000 how to write into a banner container. But this is only one of the difficulties. There are several other items that you need to pay attention to:

  • Absolute Positioning. Your SPAN element must be placed in absolute positions. Notice the STYLE attribute of our SPAN element:
    <SPAN ID="banner" STYLE="position: absolute;"><I>the banner is loading</I></SPAN>

  • Timing. You have to load the banner only after the page completes its loading. You do it by specifying the event handler:
    onload = start;

    where start() is the following function:

    function start() {
      display("banner", "Navigator behaves totally differently from Explorer");
    }

  • Open and Close Document. You can't just write to the banner. You have to open it, write to it, and close it:
    with (document[id].document) {
          open();
          write(str);
          close();
        }

Again, I cannot stress enough how much the above topics are impoartant. Here is a banner script. Try to omit some features and observe its consequences.

<HTML>
<HEAD>
<TITLE>Title Here</TITLE>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--

var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;

onload = start;

function start() {
  display("banner", "Navigator behaves totally differently from Explorer");
}

function display(id, str) {
  if (NS4) {
    with (document[id].document) {
      open();
      write(str);
      close();
    }
  } else {
    document.all[id].innerHTML = str;
  }
}

// -->
</SCRIPT>
</HEAD>
<BODY>
<SPAN ID="banner" STYLE="position: absolute;"><I>the banner is loading</I></SPAN><BR><BR>
</BODY>
</HTML>

Learn more about text banners in Column 3, Rotating Text Banners.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji