Javascript
Jeff Williamson
Northern Virginia Community College
www.nvcc.edu/home/nvwillj/html-graphics/
nvwillj@nvcc.edu
User Alerts
One of the easiest things you can do with Javascript is to put some
information in an alert box which displays before a page loads.
Click >>here<< for a demo.
Here's the code for the demo:
<HTML>
<HEAD>
<SCRIPT>
alert("By accessing this page, you
agree to the Acceptable Use Policy. See the boss for more info before
he sees you.")
</SCRIPT>
<TITLE>Success!</TITLE>
</HEAD>
<BODY>
Easy, no? This script could go anywhere.
In the <HEAD> tags above, it runs before the <BODY>
of the page can load.
At the end of a page, it would display only after elements
above it in the <BODY> loaded.
Note 1: Alert boxes are noisy and disruptive, so use them sparingly.
They are the car horns of the HTML world.
Note 2: You can't format Alert-box information. You can't use HTML tags,
and the Alert boxes themselves differ widely from browser to browser and
platform to platform.
Note 3: You also can't change the browser name and Javascript identifiers
in the Alert box. This is to prevent scripts from spoofing real
system events like logons.
|