国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS中簡單的實現像C#中using功能(有源碼下載)

2019-11-21 02:22:21
字體:
來源:轉載
供稿:網友
先看看使用頁面是如何調用的。
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
 <head> 
 <title> neverModules Using Function - http://www.never-online.net </title> 
 <meta http-equiv="ImageToolbar" content="no" /> 
 <meta name="author" content="never-online, BlueDestiny"/> 
 <meta name="keywords" content="never modules, Mozilla CSS, C#, .net, Reference, BlueDestiny, never-online"/> 
 <meta name="description" content="javascript reference, c sharp artilces"/> 
 <meta name="creator.name" content="never-online, BlueDestiny" /> 
 <style type="text/css" media="all" title="Default"> 
 body { 
 font:9pt "Verdana"; 
 } 
 </style> 
 <script type="text/javascript" src="System/system.js"></script> 
 <script type="text/javascript"> 
 //<![CDATA[ 
 Using("System.Utils.Jsclass"); 
 var jsclass = new Jsclass(); 
 jsclass.toString(); 
 //]]> 
 </script> 
 </head> 
 <body id="www.never-online.net"> 
 <p align="center">Power By never-online</a> 
 </body> 
</html> 
再看看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); 
}

下載文件 下載此文件
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 余庆县| 延长县| 安义县| 嘉定区| 罗城| 克什克腾旗| 昭平县| 衡山县| 新疆| 曲靖市| 二连浩特市| 洪湖市| 监利县| 南昌市| 白河县| 丹江口市| 晴隆县| 长岛县| 耿马| 广昌县| 玛沁县| 诏安县| 化隆| 报价| 金秀| 大洼县| 大名县| 娱乐| 南华县| 万盛区| 和平区| 株洲市| 商城县| 伊川县| 嘉善县| 大化| 卓尼县| 凤城市| 竹山县| 五莲县| 荔浦县|