Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] Javascript equivilent to C #include

Started by aftermath Dec 26, 2004 at 2:13 AM 4 replies 1.9k views
Original Post
aftermath
aftermath
Anyone know?
Rate me up.
nts
nts
put in html head portion of document to include the &#106avascript file

<script src="java_script_file.js"></script>

aftermath
aftermath
Is this possible to do withing the JS file itself?


Hmm... I suppose I could use document.write() to include another JS file...
Rate me up.
markr
markr
Some &#106avascript execution environments have methods for loading extra bits of script.<br/><br/>Unfortunately as far as I'm aware, the only one usually available in web browsers is the usage of script elements from HTML (or XHTML).<br/><br/>Mark
Coward
Coward
document.write("<scr" + "ipt src=\"filename\"></scr" + "ipt>");

It's a real pain, and I'm not sure it's executed before after the script that's currently being processed, but it's also the only way AFAIK.
Don't Temp Fate..
kanzler
kanzler
var head = document.getElementsByTagName('head').item([[0]]);var script = document.createElement('script');script.src = "external.js";script.type = 'text/javascript';head.appendChild(script);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.