By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,472 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,472 IT Pros & Developers. It's quick & easy.

Importing scripts

P: n/a
Is there a way to 'include' javascript at runtime?

I'm targeting most recent browsers in general, but at worst I'm looking
for IE/Moz solutions.

Brett
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Yes. This is the include statement:

<script type="text/javascript" src="debugmincommon.js"></script>

The name of the inlude file is specified by the src parameter. You do
not put a script header in the inluded file. The path is the normal
html path.

Robert

Jul 23 '05 #2

P: n/a
Brett Foster wrote:
Is there a way to 'include' javascript at runtime?

I'm targeting most recent browsers in general, but at worst I'm looking
for IE/Moz solutions.
Hate to reply to my own thread but after even more searching...

Here's one solution using IFrames and/or adding JS script tags to the dom.

http://www.howtocreate.co.uk/loadingExternalData.html

if( document.createElement && document.childNodes ) {
var scriptElem = document.createElement('script');
scriptElem.setAttribute('src','someNewUrl.js');
scriptElem.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(scriptElem);
}

Well it does work... not so friendly to look at, but it works.

Brett
Brett

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.