This is a discussion on Javascript code within the Programming forums, part of the Tutorials category; Embedded of Javascript code into an HTMLprogram: • Use the <script> tag (also use the type attribute to define the ...
Embedded of Javascript code into an HTMLprogram:
• 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>
Placement of Scripts:
• Scripts can be placed either in <head> section or <body> section.
• It is always good to place it in the <head> section. The <SCRIPT> tag marks the beginning of a snippet of scripting code. The paired </SCRIPT> marks the end of the snippet of scripting code.
<html>
<head>
<script type="text/javascript">
....
</script>
</head>
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>
Bookmarks