document.getElementById( ‘message’ ).innerText = ‘Hello World!’
An HTML document can include multiple scripts, and these may be placed in the head or body section of the document. It is, however, recommended that you place scripts at the end of the body section (immediately before the </body> closing tag) so the browser can render the web page before interpreting the script.
<script src=”external_script.js”> </script>
Again, this can be placed in the head or body section of the document, and the browser will treat the script as though it was written directly at that position in the HTML document.
Assigning only the file name of an external script to the src attribute of a <script> tag requires the script file to be located in the same folder (directory) as the HTML document. If the script is located in an adjacent folder you can assign the relative path address of the file instead, like this:
<script src=”js/external_script.js”> </script>
If the script is located elsewhere, you can assign the absolute path address of the file, like this:
By: Mike McGrath
By: Max Wainewright