JavaScript City

Mouseover- Multiple Alerts

A script that will bring up multiple alerts when someone moves the mouse over a link. It is set up for three alerts, but more could be added.

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

salert4.js

The code below should be placed between the <body> and </body> tags where you want the link to appear.

Example

A working sample of the script is shown below.

Don't click this link!

Options

The link text can be changed to whatever you like by editing the text between the <a> and </a> tags.

You can change the destination of the link to send the viewer someplace if JavaScript turned off by editing the src attribute of the <a> tag.

You can change the text of the alerts by opening the salert1.js file and editing the bold (strong) text on the following lines of code:

window.alert('I told you not to click the link!');
window.alert('And you did it anyway!');
window.alert('Oh Well, no more alerts after this.');

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

window.alert('I told you not to click the link!');
window.alert('And you did it anyway!');
window.alert('Oh Well, no more alerts after this.');
window.alert('Ha Ha! Fooled You! There is one more!');

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 should be more or less accessible as long as the link has a destination for the viewer to go to if activated with the keybord or with JavaScript turned off (or if the viewer's browswer is too old for the script). If the messages are important, the link should go to a page which includes the important information.

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




eXTReMe Tracker