Friday 19 January 2018

How to Add JavaScript in Head Element

We can place the SCRIPT element inside the HEAD element of the HTML document. The Script placed inside the HEAD element runs when we perform some action such as clicking a link or the submit button.
Now Here We Create a Webpage, named ScriptInsideHead.html to show how to add a script in HEAD element.

/////ScriptInsideHead.html file////
<!doctype html>
<html>
<head>
<title>Adding script in HEAD element</title>
<h1>Adding script in the HEAD element </h1>
<SCRIPT type="text/javascript">
document.write("Welcome to the World of JavaScript<br>");
document.write("In this example we have used the JavaScript in the HEAD element.")
</SCRIPT>
<body style="background-color:#fff00f">
</head>
</html>

The OutPut of the ScriptInsideHead.html file


No comments:

Post a Comment