Persistent Random Banners: Embedding the Banner | WebReference

Persistent Random Banners: Embedding the Banner


Persistent Random Banners

Embedding the Banner

As suggested in Jamie Jaworski's SuperScripter, we embed the banner in one of cell of a table. You can design your own table and fill its cells as you see fit. In our table, there is one column with two cells. The top cell includes a fixed banner, Doc JavaScript Tip of the Day. The bottom cell includes a JavaScript call to the function refreshDocJSTOD() which writes out a persistent random message. You can place the table anywhere in your page. Here is our TABLE definition:

<TABLE align=right cellpadding=4 cellspacing=1 border=2 width="40%"> 
<TR><TD align=center bgcolor="#000099">
<B><font face="Verdana,sans-serif" color="#ffcc00" size=-1>
Doc JavaScript Tip of the Day
</font></B></TD></TR> 
<TR><TD align=center bgcolor="#ffffcc">
<font face="Arial,sans-serif" size=-1>
<SCRIPT LANGUAGE="JavaScript">
refreshDocJSTOD("now");
</SCRIPT>
</font></TD></TR> 
</TABLE>

Notice that we call the function refreshDocJSTOD() with the string argument "now". The argument can take one of the following values:

Two more elements are needed for our banner. First, the JavaScript code itself. We placed it in an external file, code.js. We explain this code and give its listing later in this column. Here is how you include it in your page (in the HEAD section):

<SCRIPT language="JavaScript" src="code.js"></SCRIPT>

The second missing necessity is the message feed. The messages are stored in an external file, feed.js. The messages are HTML-formatted as we explain later in this column. To include the feed in your page, you need to call the external file somewhere in your page's HEAD section:

<SCRIPT language="JavaScript" src="feed.js"></SCRIPT>

To summarize, you need to take care of three elements in order to embed a persistent random banner in your page:

Next: How to select a message

https://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: March 27, 2000
Revised: April 26, 2000

URL: https://www.webreference.com/js/column60/2.html