Location of JavaScript:

You can insert JavaScript in HTML page as well as you can create an external JavaScript. There are two ways to create JavaScript in your HTML page and they are as follow

  • Internal JavaScript
  • External JavaScript

Internal JavaScript:

As the name says you can put JavaScript into HTML pages. But the question is “where to write JavaScript in HTML page?” the answer is “you can put JavaScript in body and head section”.

Example:

In following example we are putting JavaScript in <head>—–</head> section

Example:

In following example we are putting JavaScript in <body>—–</body> section

External JavaScript:

You already know how to create an External CSS. For creating an external JavaScript you have to select a JavaScript file and do all scripting inside that file. The question is “how to link JavaScript?” the answer is in following example

Example:

This is a HTML document code

This is a JavaScript code and we saved the JS file as “script.js”

 

 

One response to “Location of JavaScript”

  1. Samara says:

    You share interesting things here. I think that your blog can go viral easily.

Leave a Reply

Your email address will not be published. Required fields are marked *