Incorporating JavaScript in BODY Element

Using JavaScript

You can place SCRIPT tag in BODY tag of HTML document. The script inside BODY tag executes when the web page starts loading in a web browser.

Demo

Let’s create a document called ScriptInBody.html



Syntax

The syntax for placing snippet in BODY section is

  1. <BODY>  
  2. <SCRIPT type=”text/javascript”>  
  3. Script code here.  
  4. </SCRIPT>  
  5. </BODY>  
Write the script in BODY section



Execute the script by Opening the file in the Web Browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and you are using Mozilla Firefox then click on allow “ActiveX Controls”.



Thanks for reading this blog.

Ebook Download
View all
Learn
View all