Home  >  Article  >  Web Front-end  >  JavaScipt Basic Tutorial: The Basics of JavaScript Language_Basic Knowledge

JavaScipt Basic Tutorial: The Basics of JavaScript Language_Basic Knowledge

WBOY
WBOYOriginal
2016-05-16 19:06:35700browse
在什么地方插入 JavaScript
  JavaScript 可以出现在 HTML 的任意地方。使用标记<script>…</script>,你可以在 HTML 文档的任意地方插入 JavaScript,甚至在之前插入也不成问题。不过如果要在声明框架的网页(框架网页)中插入,就一定要在之前插入,否则不会运行。
基本格式
<script><br><!--<BR>...<BR>(JavaScript代码)<BR>...<BR>//--><br></script>
The purpose of the second and fourth lines is to cause browsers that don't 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