11 Years
Discussion Span
Last Post by alpha_foobar

It won't work like you want. Try this instead:

<script type="text/javascript" lang="Javascript" src="headerfile.js"/>
// your script

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 <script src="xxx.js" language="javascript> tag.

<script type="text/javascript">

			function importLibFile(file){
				var e = document.createElement("script");
				e.src = file;
				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;
				if(document.applications && !document.applications[name]){
					applicationRegister(name, func);
				} else {
					alert("web.sh: " + name + " already exists.");

			onload = function(){
				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");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.