JS中簡(jiǎn)單的實(shí)現(xiàn)像C#中using功能(有源碼下載)
更新時(shí)間:2007年01月09日 00:00:00 作者:
先看看使用頁(yè)面是如何調(diào)用的。
下載此文件
復(fù)制代碼 代碼如下:
<!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這個(gè)命名空間是如何的。
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);
}
}
接下來(lái)就是主要的Using這個(gè)函數(shù)了
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);
}
"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這個(gè)命名空間是如何的。
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);
}
}
接下來(lái)就是主要的Using這個(gè)函數(shù)了
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);
}

相關(guān)文章
Bootstrap模態(tài)框(modal)垂直居中的實(shí)例代碼
這篇文章主要介紹了Bootstrap模態(tài)框(modal)垂直居中的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08JS實(shí)現(xiàn)來(lái)回出現(xiàn)文字的狀態(tài)欄特效代碼
這篇文章主要介紹了JS實(shí)現(xiàn)來(lái)回出現(xiàn)文字的狀態(tài)欄特效代碼,針對(duì)文字的定義及狀態(tài)欄的定時(shí)顯示等實(shí)現(xiàn)方法備有詳細(xì)的文字說(shuō)明,需要的朋友可以參考下2015-10-10js實(shí)現(xiàn)輪播圖效果 z-index實(shí)現(xiàn)輪播圖
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)輪播圖效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-01-01Axios取消重復(fù)請(qǐng)求的方法實(shí)例詳解
在開(kāi)發(fā)中,經(jīng)常會(huì)遇到接口重復(fù)請(qǐng)求導(dǎo)致的各種問(wèn)題,這篇文章主要給大家介紹了關(guān)于Axios取消重復(fù)請(qǐng)求的相關(guān)資料,需要的朋友可以參考下2021-06-06js實(shí)現(xiàn)數(shù)字從零慢慢增加到指定數(shù)字示例
今天小編就為大家分享一篇js實(shí)現(xiàn)數(shù)字從零慢慢增加到指定數(shù)字示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-11-11