How To Put a JavaScript into an HTML Page

To insert a JavaScript into an HTML page, we use the <script> tag. Inside the <script> tag we use the type attribute to define the scripting language.


So, <script type="text/javascript"> and </script> tell where the Java-Script starts and ends:

<html>
<body>
<script type="text/javascript">
document.write("Hello World!");</script>
</body>
</html>

Note: If we had not typed the <script> tag, the browser would have treated the document.write(“Hello World!”) command as pure text and would just write the entire line on the page.
Share on Google Plus

About rourn vireak

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment