Home > Web Front-end > JS Tutorial > Simple implementation in JS like using function in C# (source code download)_javascript skills

Simple implementation in JS like using function in C# (source code download)_javascript skills

WBOY
Release: 2016-05-16 19:21:49
Original
1149 people have browsed it

先看看使用页面是如何调用的。

复制代码 代码如下:
html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 
  
  neverModules Using Function - http://www.never-online.net  
  
  
  
  
  
  
 <script></script> 
 <script>  <BR> //<![CDATA[  <BR> Using("System.Utils.Jsclass");  <BR> var jsclass = new Jsclass();  <BR> jsclass.toString();  <BR> //]]>  <BR> </script> 
  
  
 

Power By never-online 
  
 
再看看System.Utils.Jsclass这个命名空间是如何的。 
var System = {}; System.Utils = {}; 
System.Utils.Jsclass = function() { 
 this.name = "jsclass"; 
 this.functions = "Using function test."; 
 System.Utils.Jsclass.prototype.toString = function() { 
 document.write(this.functions); 
 } 

接下来就是主要的Using这个函数了 
var Using = function (sNamespace, bUseCache) { 
 bUseCache = bUseCache===true; 
 var x=!!document.all?new ActiveXObject("MSXML2.XMLHTTP"):new XMLHttpRequest(); 
 var shortname = sNamespace.substring(sNamespace.lastIndexOf(".") 1); 
 sNamespace = sNamespace.replace(/./g,"/") ".js"; 
 x.open("GET", sNamespace (bUseCache?"?x=" Math.random():""), false); 
 x.send(null); var code = x.responseText; 
 window[shortname]=window.eval(code); 
}


Simple implementation in JS like using function in C# (source code download)_javascript skills 下载此文件
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template