Skip to main content

JavaScript

JavaScript is the main scripting language used on the web to create interactivity with web pages. To enable JavaScript, you do this within the HTML source code of the web page, using the script tags <script></script>. Here is an example, which displays the message hello world!

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

If scripts are executed when the web page loads, the script tags should appear between the <body> tags. If the script is called during an event such as a mouse click, the script tags should go between the <head> tags.

Next: Calling a Script