How to embed javascript code in HTML pages
(Learning video sharing: html video tutorial)
<html> <body> <script type="text/javascript"> document.write("Hello World!"); </script> </body> </html>
above The code will produce this output in the HTML page:
Hello World!
Explanation of examples:
If you need to insert a piece of JavaScript into the HTML page, we need to use the <script> tag (and use the type attribute to Define scripting language). </p><p>In this way, <script type="text/javascript"> and </script> can tell the browser where JavaScript starts and ends.
<html> <body> <script type="text/javascript"> ... </script> </body> </html>
The document.write field is a standard JavaScript command used to write output to the page.
After entering the document.write command between , the browser will execute it as a JavaScript command. This way the browser will write "Hello World!" to the page.
<html> <body> <script type="text/javascript"> document.write("Hello World!"); </script> </body> </html>
Note: If we do not use the