IT Questions and Answers :)

Thursday, July 4, 2019

If you want to add a JavaScript to a webpage, you must put it inside which HTML element?

If you want to add a JavaScript to a webpage, you must put it inside which HTML element?

  • <js>
  • <script>
  • <jscript>
  • <javascript> 

EXPLANATION

Add a script tag to the HTML head. To do so, insert a <script language="javascript"> tag in the head. This tells the text editor that you'd like to use JavaScript language to write your HTML JavaScript "program." In this example, we will greet the user using an alert.

  • Add the script tag the HTML head of your own website to add JavaScript.
  • If you want the script to run automatically run when the site loads, don't include a function. If you want to call it, include a function.
<html>
<head>
<script language="javascript">
alert("Hi there, and welcome.")
</script>
</head>
<body>
</body>
</html>

 



Share:

0 comments:

Post a Comment

Popular Posts