查看: 1742|回复: 0

JScript 客户端 Request 对象

[复制链接]
发表于 2005-5-30 20:13:13 | 显示全部楼层 |阅读模式
&lt;script language=Javascript&gt;<BR>var Request = <BR>{<BR>QueryString: new ThunderBirdRequestQueryString(),<BR>Cookies: new ThunderBirdRequestCookies()<BR>}<BR>function ThunderBirdRequestQueryString(){<BR>    this.Current = document.location.search;<BR>    this.count = 0;<BR>    this.Item = new Array();<BR>    this.item = function (strKey){<BR>        if ( typeof(this.Item[strKey]) != "undefined" ){<BR>            return this.Item[strKey];<BR>        }<BR>        else{<BR>            return "";<BR>        }<BR>    }<BR>    ThunderBirdRequestOnInit(/([^?&amp;][a-z\d]*)=([^#&amp;]*)/gim, this.Current, this.count, this.Item);<BR>}<BR>function ThunderBirdRequestCookies(){<BR>    this.Current = document.cookie;<BR>    this.count = 0;<BR>    this.Item = new Array();<BR>    this.item = function (strKey){<BR>        if ( typeof(this.Item[strKey]) != "undefined" ){<BR>            return this.Item[strKey];<BR>        }<BR>        else{<BR>            return "";<BR>        }<BR>    }<BR>    ThunderBirdRequestOnInit(/([^?&amp;][a-z\d]*)=([^#&amp;;]*)/gim, this.Current, this.count, this.Item);<BR>}<BR>function ThunderBirdRequestOnInit(RegExpRule, Current, count, Item){<BR>    if ( Current != "" ){<BR>        while ( RegExpRule.exec(Current) != null ){<BR>            Item[RegExp.$1] = RegExp.$2;<BR>            Item[count] = RegExp.$2;<BR>            count += 1;<BR>        }<BR>    }<BR>}<BR>/*<BR>使用方法如下<BR>Request.QueryString 方法<BR>方法方式:<BR>按名字:<BR>document.write( Request.QueryString.item("test") );<BR>按索引<BR>document.write( Request.QueryString.item(0) );<BR><BR>数组方式<BR>按名字:<BR>document.write( Request.QueryString.Item["test"] );<BR>按索引<BR>document.write( Request.QueryString.Item[0] );<BR><BR>得到长度:<BR>document.write( Request.QueryString.count );<BR><BR>得到查询字串:<BR>document.write( Request.QueryString.Current );<BR><BR>Request.Cookies 方法 同上<BR>*/<BR>&lt;/script&gt;<BR>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条


关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:admin@discuz.vip

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖QQ客服返回顶部