JavaScript City


Page Opening with Multiple Alerts

A script that will bring up multiple alerts when someone enters your Web page. It is set up for three alerts.

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).

salert5.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 alerts by opening the salert5.js file and editing the bold (strong) text on the following lines of code:

window.alert('Welcome to my Web Site!');
window.alert('Remeber to sign the guestbook!');
window.alert('Are you annoyed yet? Muahahaha!');

Additional alerts can be added by adding additional window.alert statements:

window.alert('Welcome to my Web Site!');
window.alert('Remeber to sign the guestbook!');
window.alert('Are you annoyed yet? Muahahaha!');
window.alert('You probably don\'t like me very much right now!');

If you need to use single or double quotation marks within a quote, you should write them with a backslash before them (i.e. \" and \') in order to avoid JavaScript errors.

Accessibility

This could possibly be made accessible by repeating the information in the alerts 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