How to Include Javascript to HTMLPage with inline and external file

Description

To include JavaScript from an external file, use the src attribute to reference URL linked to a file containing JavaScript code, like this:


<script type="text/javascript" src="example.js"></script>

In the code above, an external file named example.js is loaded into the page.

The file should only contain the Javascript code.

Note

To include JavaScript files from outside domains.


<script type="text/javascript" src="http://www.java2s.com/afile.js"></script>

The script elements are interpreted in the order in which they appear in the page as long as the defer and async attributes are not present.





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions