How to put a JavaScript code into
an HTML page?
Use the <script> tag (also use the type attribute to define the
scripting language)
<html>
<head>
<script type="text/javascript">
...
</script>
</head>
<body>
<script type="text/javascript">
...
</script>
</body>
</html>
Where Do You Place Scripts?
Scripts can be in the either <head> section or
<body> section
• Convention is to place it in the <head> section
<html>
<head>
<script type="text/javascript">
....
</script>
</head>
Referencing External JavaScript
File
Scripts can be provided locally or remotely
accessible JavaScript file using src attribute
<html>
<head>
<script language="JavaScript"
type="text/javascript"
src="http://somesite/myOwnJavaScript.js">
</script>
<script language="JavaScript"
type="text/javascript"
src="myOwnSubdirectory/myOwn2ndJavaScript.js">
</script>
an HTML page?
Use the <script> tag (also use the type attribute to define the
scripting language)
<html>
<head>
<script type="text/javascript">
...
</script>
</head>
<body>
<script type="text/javascript">
...
</script>
</body>
</html>
Where Do You Place Scripts?
Scripts can be in the either <head> section or
<body> section
• Convention is to place it in the <head> section
<html>
<head>
<script type="text/javascript">
....
</script>
</head>
Referencing External JavaScript
File
Scripts can be provided locally or remotely
accessible JavaScript file using src attribute
<html>
<head>
<script language="JavaScript"
type="text/javascript"
src="http://somesite/myOwnJavaScript.js">
</script>
<script language="JavaScript"
type="text/javascript"
src="myOwnSubdirectory/myOwn2ndJavaScript.js">
</script>
No comments:
Post a Comment