Fast Info For Your Visitors
Permission is granted to reprint the article below in its entirety provided no changes are made to the article text and the author's name, signature lines, and copyright line are printed with the article. However, you may change the article's title.
You click a word; immediately a definition is displayed. You click a phrase; immediately you see a concept explained. You click, the data pops up in a box. No delay. This Fast Info method uses JavaScript alert boxes to deliver instant information. Implementing the Fast Info method is a simple two steps.
To demonstrate those two steps, we'll use an example. The example assumes you have the following text somewhere on your webpage:
and you want to link "written word" to an alert box with the definition of a written word. The link and alert box need a common yet unique name. Let's call it "defword". With "defword" as the name, this is how you place the link:
Thus, we use <a href="Javascript:defword()">written word</a>s. That places the link into your webpage. Now, step number 2. The way to place the alert box is to put a JavaScript function between the <head> and </head> tags of your webpage. Assuming the link and alert box name to be "defword":
<script><!--
function defword() {
var s = '' +
'';
alert(s);
}
//-->
</script>
Notice there is a blank line, between the var s = '' + line and the ''; line. That is where the message will go; in this case, the definition of "written word".
Replace that blank line with your message. When your message is finished, put an apostrophe (single quote) at the beginning of each typed line. Then put an apostrophe-space-plus sequence of characters at the end of each typed line. It will look something like this:
'A string of characters ' + 'whose sequence holds a ' + 'significance for the ' + 'viewer.' + The above will all string together as one paragraph when the alert box is shown. If you want to force a line break, use the characters:
\n If you want a blank line between paragraphs, use the above set of characters twice.
So, using our word definition example, the final alert box code looks like this:
<script><!--
function defword() {
var s = '' +
'A string of characters ' +
'whose sequence holds a ' +
'significance for the ' +
'viewer.' +
'';
alert(s);
}
//-->
</script>
And when you click the "written word" link on your webpage, an instantaneous JavaScript alert box presents itself, containing the message, "A string of characters whose sequence holds a significance for the viewer." This Fast Info method has some limitations. Nothing this good is the answer to everything. The primary limitation is that alert boxes must be closed by clicking the "OK" button at the bottom of the message area or by pressing the keyboard's "enter" key. This means your messages are limited to the size of your user's computer screen. There are no scroll bars. (If the alert box grows too big, the "OK" button will be below the screen's bottom edge -- the button can't be clicked on. This condition can lead the user to believe s/he is locked out of the browser.) For a 640 x 480 pixel screen, you are limited to about 25 lines. And a message composed of one large paragraph has a limitation of about 1500 characters. WebTV screens are smaller still, 570 pixels wide. Thus, you may wish to stay well below the above limits. Larger screens, of course, can display larger messages; but just because your screen is larger doesn't mean all of your user's will be. Another limitation is that you can't use pictures. Also, browsers must be JavaScript enabled for the Fast Info method to work. Without JavaScript, the links do nothing. Happy elucidating! If you need help with it let me know. Copyright 1999 by William Bontrager
William Bontrager, Programmer and Publisher
|