Mix complicated code with HTML : Source File « Language Basics « JavaScript Tutorial






<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--

//  -->
</script>
</head>
<body>
<p onclick="units = prompt('How many do you want','Enter quantity');alert('Cost per unit is $9.99, therefore total cost for ' + units + ' is ' + units * 9.99);">Click here to specify quantity</p>
</body>
</html>








1.7.Source File
1.7.1.Use the 'script' tag to incluse your javascript code
1.7.2.HTML Template Page supporting the JavaScript
1.7.3.Define script in HEAD section
1.7.4.Define javascript code in BODY section
1.7.5.Define message in one block and output it in another
1.7.6.Reference javascript source file stored outside
1.7.7.Mix simple code with HTML
1.7.8.Mix complicated code with HTML