The javascript alert is beneficial to the javascript programmer for several different reasons. The javascript alert can give feedback on variables within your script, let your site visitor know what they should do next or why they cannot proceed, and the alert can also let you know when your script is breaking.
This post assumes that you have read the javascript intro I posted a couple of days ago. To write javascript code in your page, you must be writing the javascript between script tags, in a .js file, or even (and I did not mention this on my last post) in an event handler.
To script an alert in your code, this is the appropriate syntax:
alert(’You just clicked a button!’);
And here is an example (click on the button below):
This alert was called through an ‘onclick’ event handler. The html syntax for this button is below:
<input type=”button” name=”mybutton” value=”Click Me!” onclick=”alert(’You just clicked a button!’);” />
Like this tutorial? Stay tuned for more.
Leave a Reply