" tag pair through the script tag. When the browser loads the Body part of the web page, it will execute the Javascript statement in it, and the output content after execution will be displayed on the web page."/>
" tag pair through the script tag. When the browser loads the Body part of the web page, it will execute the Javascript statement in it, and the output content after execution will be displayed on the web page.">
Home > Article > Web Front-end > Can javascript be written in the body?
Javascript can be written in the body. Write the Javascript code in the "" tag pair through the script tag. When the browser loads the Body part of the web page, it will execute the Javascript statement in it, and the output content after execution will be displayed on the web page.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
The placement location of Javascript:
Html web page6c04bd5ca3fcae76e30b72ad730ca86d36cc49f0c466276486e50c850b7e4956;
Html The webpage's 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1;
##Javascript is written in6c04bd5ca3fcae76e30b72ad730ca86d36cc49f0c466276486e50c850b7e4956
When the browser loads the Body part of the web page, it executes the Javascript statements in it, and the output content after execution is displayed on the web page.<html> <head></head> <body> <script type="text/javascript">....</script> </body> </html>
Javascript is written in 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1
Sometimes it is not necessary to run Javascript as soon as the HTML is loaded, but when the user clicks When an object in HTML triggers an event, Javascript needs to be called. At this time, such Javascript is usually placed in 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1 of HTML.<html> <head> <script type="text/javascript">....</script> </head> <body> </body> </html>Javascript is written after 6c04bd5ca3fcae76e30b72ad730ca86d
<html> <head></head> <body> </body> <script type="text/javascript">....</script> </html>
The difference between js code written after body, head and body
The computer reads the code The order is read from top to bottom. The order in the html file is 93f0f5c25f18dab9d176bd4f6de5d30e→6c04bd5ca3fcae76e30b72ad730ca86d→behind bodyjavascript advanced tutorial]
The above is the detailed content of Can javascript be written in the body?. For more information, please follow other related articles on the PHP Chinese website!