To use the same script on multiple pages, you should
Listing shows the reference to the external file.
Listing: External Script Reference<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
(the rest of your HTML page goes here)
Adding the src attribute to the <script> tag tells the browser to look for that external file in the specified path. The resulting Web pages look and act like the scripts are in the header or body of the page’s script tags, though the script is in the external .js file.
If you use a script on only one page, it’s often easier simply to put the script on the page in a body or header script.
If you have multiple external .js files, you can use any or all of them on any HTML page. Just include multiple <script> references on the page. It’s perfectly okay for a page to include multiple scripts and to both refer to external .js files and include its own scripts inside <script> tags.
When you have multiple <script> tags defined in your Web page, the browser processes them in the order in which they are declared. If, for some reason, you have an external .js file that conflicts with a script inside a <script> tag, the last one defined wins.
Note that the contents of the .js file shown in Listing could be copied directly into a <script> tag and function identically.
HTML 4 Related Interview Questions
|XML Interview Questions||HTML 4 Interview Questions|
|HTML Interview Questions||HTML 5 Interview Questions|
|HTML DOM Interview Questions||Java Interview Questions|
|CSS Interview Questions||Java Abstraction Interview Questions|
|Dynamic HTML Interview Questions||XHTML Interview Questions|
Html 4 Tutorial
The Least You Need To Know About Html And The Web
Creating And Viewing A Web Page
Proper Planning Prevents Poor Page Performance
Creating (x)html Document Structure
Text And Lists
Linking To Online Resources
Finding And Using Images
Introducing Cascading Style Sheets
Using Cascading Style Sheets
Getting Creative With Colors And Fonts
Using Tables For Stunning Pages
Scripting Web Pages
Working With Forms
Fun With Client-side Scripts
The About Me Page
The Ebay Auction Page
A Company Site
A Product Catalog
Ten Cool Html Tools
Ten Html Do’s And Don’ts
Ten Ways To Exterminate Web Bugs
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.