Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More than one external javascript file

Status
Not open for further replies.

prizm

Programmer
Jul 19, 2004
5
US
Is it possible to associate more than one external javascript file to a single page? If so, when calling a function within one of the files would you use the file name extension?
 
>> "Is it possible to associate more than one external javascript file to a single page?"
yes
e.g.
<script type="text/javascript" src="foo.js"></script>
<script type="text/javascript" src="bar.js"></script>

>> "If so, when calling a function within one of the files would you use the file name extension?"
no, they are included as if they were written on the same page. you reference them by their name, and all function names must be unique.
e.g.
if foo.js contains method foo() and bar.js contains method bar(), you simply call foo() or bar()

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Make sure you don't have variables or functions in one of the files that are named the same as variables or functions within the other. This would cause a conflict, and could lead to very ambiguous results, or code not working at all.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top