Example 1
<HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Hide script from old browsers function square(number) { return number * number; } // End script hiding from old browsers --> </SCRIPT> </HEAD><BODY> <SCRIPT> document.write("The function returned ", square(5), "."); </SCRIPT> <P> All done. </BODY>Example 2
<HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Hide script from old browsers function checkOk() { yn=confirm('O.K.?'); if (yn) alert('Yes'); else alert('No'); return true; } // End script hiding from old browsers --> </SCRIPT> </HEAD><BODY> ... <input type="button" value="O.K" onClick="checkOK()"> ... </BODY>