Peter
New Member
God
Posts: 6
|
Post by Peter on Jun 18, 2004 11:48:10 GMT
This will just be a very simple tutorial for complete beginners. In order to include Javascript in a document, a script block must first be defined in the HTML code. The script block can be put anywhere within the HTML code, but usually it would go into the head part of the document between the <head> tags. When the document loads it reads the code, so placing it in the head of the document ensures that the Javascript code is read before the HTML content. Example of a script block: <script type="text/javascript"> <!--
//--> </script>
Note: you might see some script blocks that contain the language attribute, this was used to specify the scripting language but I believe it has been removed in HTML 4.0. So the actual code you make would go between <!-- and //-->. What they are is to hide the script from really old browsers. You may also separate the javascript code from the HTML code by putting the javascript code into a JS file. A JS file is just a text document with the javascript code in it but without any script or HTML tags. A javascript file is saved with the extension ".js". So now, to call the JS file to be loaded into the document, you would use a script block like so: <script type="text/javascript src="http://www.mydomain.com/myscript.js"></script>
Just a simple one, will try to make a few more when I can Peter You may not repost this anywhere else without my permission
|
|