Javascript Intro
Javascript Intro
Introduction
JavaScript is a scripting language most often used for
JavaScript,
But in general, semicolons are optional!
Browsers that do not support JavaScript will display the script as page content. To
prevent them from doing this, we may use the HTML comment tag:
<script type="text/javascript">
<!–
document.write("Hello World!")
//-->
</script>
The two forward slashes at the end of comment line (//) are a JavaScript comment
symbol. This prevents the JavaScript compiler from compiling the line.
JavaScript Head Vs Body
CALLED.
External JS
Sometimes you might want to run the same
JavaScript on several pages, without having to write
the same script on every page.
To simplify this, you can write a JavaScript in an
external file. Save the external JavaScript file with a .js
file extension.
Note: The external script cannot contain the <script>
tag!
To use the external script, point to the .js file in the
"src" attribute of the <script> tag:
External JS
JavaScript Variables