Home  >  Article  >  Web Front-end  >  HTML Tutorial – Script

HTML Tutorial – Script

黄舟
黄舟Original
2016-12-26 15:23:411624browse

Add scripts to HTML to make it more dynamic and interactive.

Inserting scripts into HTML pages
Scripts in HTML are defined using the <script> tag. Note that you can use the type attribute to specify the scripting language. </p> <p><html><br><head><br></head><br><body></p> <p><script type="text/javascript"> <br>document.write("Hello World!")<br></script>


The above script outputs the following results:

Hello World!

Tip: If you need to learn more about scripting in HTML, visit our JavaScript Tutorial

How to Cope Older browsers
If the browser cannot recognize the <script> tag at all, the content contained in the <script> tag will be displayed on the page as text. To avoid this happening, you should hide your scripts in comment tags. Older browsers (those that do not recognize the <script> tag) will ignore these comments and therefore will not display the content of the tag on the page. And those new browsers will understand these scripts and execute them, even if the code is nested within comment tags. </p> <p> </p> <p>Example<br>JavaScript:<br><script type="text/javascript"><br><!--<br/>document.write("Hello World!")<br/>//--><br></script>

VBScript:

< ;noscript> Tag

In addition to hiding scripts in comments, you can also add the

VBScript: