[Contents]

jsEditor - Boilerplate Code - Alert's Link

Aim: to demonstrate boilerplate code inserting a link for an alert

Make an alert and surround it with JavaScript tags. Check a previous lesson if you are unsure what to do. You should have code similar to the following:

<SCRIPT LANGUAGE="JAVASCRIPT">

<!--//

alert("Hello");

//-->

</SCRIPT>

Select the line beginning alert( ... and right-click over the JS mode button. Choose Function. Double-click on MyFunction in the box that appears and type helloAlert(). Because the box contains the example 'MyFunction()' with double brackets, you know you have to type double brackets when you change the function name. If your code was the same as the above, then you would have:

<SCRIPT LANGUAGE="JAVASCRIPT">

<!--//

function helloAlert(){

alert("Hello");

}

//-->

</SCRIPT>

  1. Click below the script tags (below </SCRIPT>).
  2. Type "Click" and select it. Choose Wizards - Dummy Link Wizard from the main menu.
  3. The Dummy Link Wizard will appear.
  4. Check onClick and type helloAlert() in the box.
  5. Press F9 or click the Preview tab. Click on the text "Click" and you get your alert.

The code is as follows:

<SCRIPT LANGUAGE="JAVASCRIPT">

<!--//

function helloAlert(){

alert("Hello");

}

//-->

</SCRIPT>

<a href="#" onClick="helloAlert()">Click</a>

You have learned a little more about using boilerplate code and about using Wizards. Note we are not concerned that the page isn't a proper HTML page - no BODY etc. When developing scripts we try to keep everything as simple as possible.

Next Document.write Wizard