初學(xué)prototype,發(fā)個JS接受URL參數(shù)的代碼
更新時間:2006年09月25日 00:00:00 作者:
復(fù)制代碼 代碼如下:
<script>
function request(key)
{
if(typeof(this)=="undefined")return false;
if(this.length>0)
{
var s = this.split("&");
for(var i in s)
{
var sp=s[i].split("=")
if(sp[0]==key)return(sp[1]);
}
return false;
}
else return false
}
function getAllKey()
{
if(typeof(this)=="undefined")return false;
var arr=new Array;
if(this.length>0)
{
var s = this.split("&");
for(var i in s)
{
var sp=s[i].split("=");
arr.push(sp[0]);
}
return arr;
}
else return false
}
String.prototype.request=request
String.prototype.getAllKey=getAllKey
//===================================================
var url=location.search.substr(1) //action=reply&forum=3&topic=1469
var arg=url.getAllKey()
alert(arg)
document.write("提交參數(shù):"+arg)
for(var cou in arg )
document.write("<br>參數(shù)"+arg[cou]+"的值為:"+url.request(arg[cou])+"<br>")
</script>
相關(guān)文章
prototype Element學(xué)習(xí)筆記(篇二)
這一篇主要是要總論Element的所有函數(shù)。2008-10-10
Prototype 學(xué)習(xí) 工具函數(shù)學(xué)習(xí)($方法)
$方法——被成為瑞士軍刀$方法使用技巧。2009-07-07
Prototype Selector對象學(xué)習(xí)
這個對象在幫助文檔上并沒有,但是這個對象確是整個DOM操作的核心類,工具函數(shù)$$,其實(shí)就是調(diào)用這個類的方法2009-07-07
Prototype RegExp對象 學(xué)習(xí)
幫助文檔上沒有這個對象,實(shí)際上源代碼中這個對象還是有方法的,就1靜態(tài)方法,作用也不是很大,這里簡單說一下,因?yàn)橐院蠼榻B別的對象時會用到這個RegExp2009-07-07
prototype 源碼中文說明之 prototype.js
prototype 源碼中文說明之 prototype.js...2006-09-09

