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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to include code from files

Status
Not open for further replies.

heftymike

IS-IT--Management
Oct 13, 2000
4
US
Is there a command to import code into a javascript from within that javascript? Part of the code to be included exists in another .js file. [sig][/sig]
 
pete

Thanks, but I'm looking to pull code into somefile.js file from another another.js file. Can this be done? [sig][/sig]
 
Not without a server-side method. Unfortunately, as of now Javascript still won't let you nest SRC calls. A server-side include (SSI) is a relatively simple bit of code, and they are supported on most modern webservers. [sig][/sig]
 
Another thing you can do, though, is to call multiple files with multiple <Script> blocks. Variables set in one block can be available to the code from the other block(s). If you combine this with some judicious use of the eval() function, you might be home free :). [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top