HTML <script> src attribute
HTML <script> tag
Example
Link to an external script file:
<script type="text/javascript" src="myscripts.js"></script>
|
Try it yourself!
|
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
Attribute Values
Value |
Description |
URL |
The URL of the external script. Possible values:
- An absolute URL - points to another web site (like src="http://www.example.com/example.js")
- A relative URL - points to a file within a web site (like src="/scripts/example.js")
|
HTML <script> tag
Whether you're new to XML or already an advanced user, the user-friendly views
and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to
meet your XML and Web services development needs from start to finish.
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- Support for Office Open XML (OOXML)
- Graphical WSDL editor & SOAP debugger
- Java, C#, C++ code generation
- And much more!
Download a fully functional free 30-day trial today!
|