Home  >  Article  >  Web Front-end  >  JavaScript introductory tutorial (2) JS basic knowledge_basic knowledge

JavaScript introductory tutorial (2) JS basic knowledge_basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:56:32896browse

Where to insert JavaScript
 JavaScript can appear anywhere in HTML. Using the tags <script>…</script>, you can insert JavaScript anywhere in the HTML document, even before . However, if you want to insert it into the web page that declares the frame (frame web page), you must insert it before , otherwise it will not run.
Basic format

Copy code The code is as follows:

<script> <br><!-- <BR>... <BR>(JavaScript code) <BR>... <BR>//--> <br></script>

The second and fourth lines are used to cause browsers that do not understand the <script> tag to ignore the JavaScript code. Generally you can omit it, because now if you want to find a browser that doesn't understand Script, I'm afraid there is no one even in the museum. The double backslash "//" in front of the fourth line is a comment mark in JavaScript, which we will learn later. <br><br>Another way to insert JavaScript is to write the JavaScript code into another file (this file should usually have a ".js" extension), and then use the format "<script src=" javascript.js "></script>" tag embeds it into the document. Note that it must be marked with "".
Reference The