Example Link to an external script file: <script type="text/javascript" src="myscripts.js"></script> ...
Example
Link to an external script file:<script type="text/javascript" src="myscripts.js"></script> |
Definition and Usage
The src attribute specifies the URL of an external script file.Sometimes you want to run the same JavaScript on several pages in a web site. Instead of writing the same script over and over again, create your JavaScript in a standalone file, save it with a .js extension, and then refer to it using the src attribute in the <script> tag.
Note: The external script file cannot contain the <script> tag!
Note: Remember to place the script exactly where you normally would write the script!
Browser Support
The src attribute is supported in all major browsers.Syntax
<script src="URL"> |
Attribute Values
Value | Description |
---|---|
URL | The URL of the external script.Possible values:
|