hai

i want declare

imports system.net -----header file in javascript

<script>
//// in this section how to declare imports system.net
<script>

please help me

Recommended Answers

All 3 Replies

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

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

i want to declare the header file in javascript.....

please help me.....

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;
				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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.