Friday 19 January 2018

How to Add JavaScript in the Body Element

We can also place the SCRIPT element inside the BODY element of an HTML document. The script element inside the BODY element runs when the Web page starts loading in Web browser.
Now create a webpage, named ScriptInsideBody.html which shows how to add a script in BODY element.

*****ScriptInsideBody.html file*****

<!doctype html>
<html>
<head>
<title>Adding script in BODY element</title></head>
<body style="background-color:#ffffff">

<h1>Adding script in the BODY element </h1>
<SCRIPT type="text/javascript">
document.write("Welcome to the World of JavaScript<br>");
document.write("In this example we have used JavaScript in the BODY element.")
</SCRIPT>
</body>

</html>

*****Shows the output of the ScriptInsideBody.html file ********





No comments:

Post a Comment