•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,146 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,154 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1365 | Replies: 3
![]() |
•
•
Join Date: May 2006
Location: Birmingham, AL
Posts: 33
Reputation:
Rep Power: 3
Solved Threads: 5
It won't work like you want. Try this instead:
<script type="text/javascript" lang="Javascript" src="headerfile.js"/> <script> // your script </script>
•
•
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation:
Rep Power: 4
Solved Threads: 3
You can't "import" a javascript file with a javascript file.
There is an import (and export) keyword in the javascript, but these are used for visibility of members.
I wrote some code to import libraries as the user required them... but its pretty rough. This should theoretically allow dynamic importing. But if you know what you want to use, then just use the
There is an import (and export) keyword in the javascript, but these are used for visibility of members.
I wrote some code to import libraries as the user required them... but its pretty rough. This should theoretically allow dynamic importing. But if you know what you want to use, then just use the
<script src="xxx.js" language="javascript> tag. <script type="text/javascript">
function importLibFile(file){
var e = document.createElement("script");
e.src = file;
e.type="text/javascript";
document.getElementsByTagName("head")[0].insertBefore(e, document.getElementsByTagName("script")[0]);
}
function applicationRegister(appName, appFunction){
document.applications[appName] = appFunction;
document.applications[document.applications.length] = appName;
}
function init(){
document.applications = new Array();
document.libraries = new Array();
}
function setKeyListener(node, listener){
node.onkeydown = listener;
node.onkeyup = null;
}
function dropKeyListener(node){
node.onkeydown = null;
node.onkeyup = null;
}
function registerMainFunc(name, func){
// threading would be nice here.
function loadApplication(){
try {
applicationRegister(name, func);
} catch(exception) {
// while appfunction doesn't load
setTimeout(function(){ registerMainFunc(name, func); }, 250);
}
};
}
function loadApplication(name, func, libFile){
if(document.libraries && !document.libraries[libFile]){
document.libraries[libFile] = true;
importLibFile(libFile);
}
if(document.applications && !document.applications[name]){
applicationRegister(name, func);
} else {
alert("web.sh: " + name + " already exists.");
}
}
onload = function(){
init();
loadApplication("wevents", function(args, out){ __wevents_init(args, out); }, "javascript/wevents.js");
loadApplication("clear", function(args, out){ __websh_clear(args, out); }, "javascript/webshutils.js");
loadApplication("terminal", function(args, out){ __websh_terminal(args, out); }, "javascript/webshutils.js");
loadApplication("yubnub", function(args, out){ __yubnub_init(args, out); }, "javascript/yubnub.js");
loadApplication("wjsc", function(args, out){ __wjsc_main(args, out); }, "javascript/wjsc.js");
}
</script>![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- header file/ classes (C++)
- compile header file (C++)
- Link source code and header file together? (C++)
- How to write a header file (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Dynamic population of second list box based on the selection of first list box from s
- Next Thread: Page change event.


Linear Mode