Reply
Import javascript in javascript
Old 05-20-2007, 04:36 AM Import javascript in javascript
Average Talker

Posts: 25
I know that I can import an css file in other css file with @import
Ex: @import "style.css"; and i use this in allcss.css

Can I do something like this in javascript, import a javascript in other javascript ;
Alexandro is offline
Reply With Quote
View Public Profile Visit Alexandro's homepage!
 
When You Register, These Ads Go Away!
Old 05-21-2007, 11:03 AM Re: Import javascript in javascript
willcode4beer's Avatar
Webmaster Talker

Posts: 696
Name: Paul Davis
Location: San Francisco
Try this:
Code:
<script type="text/javascript">
function importScript(url){
    var tag = document.createElement("script");
    tag.type="text/javascript";
    tag.src = url;
    document.body.appendChild(tag);
}
window.onload = function(){
    // imports go here
    importScript("foo.js"); // example
};
</script>
__________________
Paul Davis
willCode4Beer.com (coding for all the right reasons)
willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Import javascript in javascript
 

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


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


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

 


Page generated in 0.10518 seconds with 12 queries