JavaScript City

Page Opening Alert

This script will bring up a JavaScript alert when someone opens your Web page.

Script Code

Grab a copy of the file below and place it in the same directory as the Web page on which you will use the script (if you wish to place the script file in a different directory you will need to make the necessary adjustments to the src attribute of the script tag that calls it).

salert2.js

The code below should be placed between the <head> and </head> tags or between the <body> and </body> tags (probably near the opening <body> tag).

Example

A working sample of the script is shown below. Click the link to get the page with the alert.

Example Link

Options

You can change the text of the alert by opening the salert2.js file and editing the bold (strong) text on the following line of code:

window.alert("Welcome to my Web Site!");

Accessibility

This could possibly be made accessible by repeating the information in the alert someplace on the actual Web page. It would be redundant, but would provide the content for viewers with JavaScript off.

It should be noted that this script can be quite irritating and probably should be avoided by professional sites unless absolutely necessary.




eXTReMe Tracker