初学prototype,发个JS接受URL参数的代码
更新时间:2006年09月25日 00:00:00 作者:
复制代码 代码如下:
<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("提交参数:"+arg)
for(var cou in arg )
document.write("<br>参数"+arg[cou]+"的值为:"+url.request(arg[cou])+"<br>")
</script>
相关文章
由prototype_1.3.1进入javascript殿堂-类的初探
由prototype_1.3.1进入javascript殿堂-类的初探...2006-11-11prototype Element学习笔记(Element篇三)
上一篇把Element的所函数都梳理了一遍,下面总结一下这些函数的功能,毕竟函数太多,不分门别类一下还是没有底。2008-10-10
最新评论