JavaScript and HTML Document
There are several ways to put JavaScript code in the document / HTML page:
Using the <script> tag
By using this method, when accessing an HTML page we should wait until it completes the process of calling the page entirely, before we run The JavaScript program. Process execution of HTML code to display one page is done from top to bottom, the more users who access these pages (and often can not wait ...) can disturb the calling process. In cases where calling a JavaScript function before the call to the JavaScript code is done by the navigator, it will show error message.
Therefore, to avoid the above events, then in general we put <script> between the head tags of an HTML document, which is part of <HEAD> tag and </ HEAD>. JavaScript function calls (also called events) were placed on the body of an HTML document or we can call between the <BODY> and </ BODY> tag.
Additional information on the tag <script> indicate the type of language used and its version, for example "JavaScript", "JavaScript1.1", "JavaScript1.2" and for the JavaScript language or other languages, for example, "VBScript".
If we want to use some version of JavaScript in a single HTML page (To adjust the compatibility of the navigator), then we just need to put JavaScript code (based on his version) to a few <script> tags by including the JavaScript version.
Using external fileThe next way is to write JavaScript code in a text file and then a text file containing JavaScript code be called from within an HTML document. The code that we insert into the HTML document is as follows:
There are several ways to put JavaScript code in the document / HTML page:
Using the <script> tag
By using this method, when accessing an HTML page we should wait until it completes the process of calling the page entirely, before we run The JavaScript program. Process execution of HTML code to display one page is done from top to bottom, the more users who access these pages (and often can not wait ...) can disturb the calling process. In cases where calling a JavaScript function before the call to the JavaScript code is done by the navigator, it will show error message.
Therefore, to avoid the above events, then in general we put <script> between the head tags of an HTML document, which is part of <HEAD> tag and </ HEAD>. JavaScript function calls (also called events) were placed on the body of an HTML document or we can call between the <BODY> and </ BODY> tag.
Additional information on the tag <script> indicate the type of language used and its version, for example "JavaScript", "JavaScript1.1", "JavaScript1.2" and for the JavaScript language or other languages, for example, "VBScript".
If we want to use some version of JavaScript in a single HTML page (To adjust the compatibility of the navigator), then we just need to put JavaScript code (based on his version) to a few <script> tags by including the JavaScript version.
Using external fileThe next way is to write JavaScript code in a text file and then a text file containing JavaScript code be called from within an HTML document. The code that we insert into the HTML document is as follows:
<script Language="JavaScript" SRC="url/javascript_file.js"> </ SCRIPT>
Where is the url/javascript_file.js is the location and name of the file containing JavaScript code, if the command is not included then additional SRC tag script will look for code that is located inside the script tag.
Through the particular events Event is the name of an action done by the user, such as mouse button click. The code can be written as follows:
<tag eventHandler="Javascript code that will be used">
eventHandler is the name of the event.
0 comments:
Post a Comment