What is the method of embedding JavaScript into a web page?
This article mainly explains "what is the method of embedding JavaScript into a web page". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of embedding JavaScript into a web page".
Embedding method: 1, use the "js code" statement; 2, write the code into the external JavaScript file, embed the src attribute of the script tag; 3, in the HTML tag, set the value of the event attribute to the code in the form of "_ JavaScript:xxx".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Three methods of embedding JavaScript into Web pages
1. Use. Label pair
Write the js code directly in the script tag pair. The script tag can be written in either the head tag or the body tag. Note:
If the JavaScript code is placed in a tag: it is mainly used to complete the required background tasks
If the JavaScript code is placed in a tag: used to display the content.
two。 Bring in external JavaScript files
This approach is generally used in enterprise work, because it ensures that js code and html code are independent and less interfering with each other (low coupling).
The mylife.js file is as follows: write the js code directly, and the js file must not appear again. B tag right!
3. Pseudo-URL introduction
This approach usually appears in the format "_ JavaScript: XXXXX", followed directly by the js code.
Thank you for your reading, the above is the content of "what is the method of embedding JavaScript in the web page". After the study of this article, I believe you have a deeper understanding of what the method of embedding JavaScript in the web page is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!