Reply
Including one .js file in another
Old 04-16-2006, 07:23 PM Including one .js file in another
Junior Talker

Posts: 1
Hello,

I am trying to include functions and data structures described in one .js file into another.

The HTML file includes the .js file like so:

Code:
<script language="javascript" type="text/javascript" src="include.js"></script>
And I tried to include the second .js file from within "include.js" like so:

Code:
document.write("<script language=\"javascript\" type=\"text/javascript\" src=\"include1.js\"></script>");
But I get an error whenever the page executes. It seems that the text in "include1.js" is parsed by the browser, but it can not be referenced from "include.js" until the page has finished loading.

Help would be much appreciated.
ch41nbr8kr is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-17-2006, 12:38 AM Re: Including one .js file in another
vangogh's Avatar
Post Impressionist

Latest Blog Post:
A Focused Blog Is A Happy Blog
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
Why not just copy the info from the second file and past it into the first one. Alternatly just add it into the html file directly. You can have more than one <script> tag in your html so just include both of your .js files directly in the html file.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 04-19-2006, 08:56 PM Re: Including one .js file in another
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
You can do as vangogh mentioned, or include the seconed file into the first one like this:
Code:
include ("/path/to/your/file.js");

Last edited by Anacrusis : 04-19-2006 at 08:57 PM.
Anacrusis is offline
Reply With Quote
View Public Profile Visit Anacrusis's homepage!
 
Old 04-20-2006, 04:36 AM Re: Including one .js file in another
AnimeTheme's Avatar
Junior Talker

Posts: 2
Try breaking up the last </script> into 2 parts.

document.write("...</scr" + "ipt>")

This is the case for inline scripts because you can't have another "</script>" within the script tags or there will be parsing errors (not sure about the case of separated .js file though).
__________________
Anime Theme - Anime and Final Fantasy wallpapers, mini-games, and other downloads!

http://www.animetheme.com
AnimeTheme is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Including one .js file in another
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12860 seconds with 13 queries