Ken Ward's Java Script Tutorial ...

Ken Ward's Java Script Tutorial ...

Doing it without a button - Text Alerts

In the previous lesson we learned how to make an alert button. However, you do not need a button to do an alert! Click here to see.

Here is the code:

<a href="index.html" onclick="alert('Don\'t forget to press the back button to return!')">

here.

</a>

This code starts off just like any hyperlink with

<a href="index.html" onclick="alert('Don\'t forget to press the back button to return!')">

The only thing funny about this one is the strange Don\'t! The \ tells the browser that this apostrophe (') is part of text and not part of the program. So remember, when you have words  with apostrophes or quotations in your message, put a \ before the apostrophe or quotation mark to tell the browser this is text and not part of the program! This is important because even when you cut and paste, without knowing about the code, you often have to add text. If you add a word with an apostrophe or quotation mark, then you may get a Java Script error, if you don't use the \. You might think there is something wrong with the program when it is your text that is causing the problem!


 [an error occurred while processing this directive]