HOW we can embed Javascript into HTML document
Javascript is added to an HTML page using SCRIPT tag. The script tags should be placed inside the head tag of the document. Javascript code should be placed inside an HTML comment tag set. Example : <!-code->When it is used with javascript's the ending comment tag will also start with 2 slashes // which is the javascript code for comment. This comment tells the javascript interpreter to ignore that statement . This is a standard way for adding javascript to your HTML pages so that it works properly for browser that javascript are enabled and those that donot support javascript.
Syntax of embedding javascript into HTML document is:
<HTML>
<HEAD>
<TITLE>Web page containing Javascript</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!- hide Javascript code from browsers that are not javascript enabled.(Javascript statements are written here)
//end hiding of javascript code ->
</SCRIPT>
<BODY>
(HTML document is written here)
</BODY>
</HTML>
We may also put in a single line of code that is attached to an event. In this statement must end with a semicolon. Javascipt is a case-sensitive language . This is how we can embed Javascript code into an HTML document.
No comments:
Post a Comment