当前位置: 代码迷 >> JavaScript >> 怎么取得open("xxx.htm?name=abc")里的参数值,
  详细解决方案

怎么取得open("xxx.htm?name=abc")里的参数值,

热度:315   发布时间:2012-02-10 21:27:41.0
如何取得open("xxx.htm?name=abc")里的参数值,在线等!
如题,以前见过,但忘了,谢谢!!

------解决方案--------------------

JScript code
var Request = function(arg){
    var ws = location.search.substring(1, location.search.length);
    var arrReturn = new Array();
    var strReturn = new String();

    if (ws != ""){
        var val = ws.split("&");
        for (i=0 ; i<val.length ; i++){
            if (arg == val[i].split("=")[0]){
                strReturn = val[i].split("=")[1];
                break;
            }
            else{
                arrReturn.push(val[i].split("=")[1]);
            }
        }
    }
    return (typeof arg == 'undefined')?arrReturn:strReturn;
};

------解决方案--------------------
protected void Page_Load(object sender, EventArgs e)
{
strint ss= Request.QueryString["name"].ToString();
}
------解决方案--------------------
var str = location.search.substring(1);
var array = str.splite(=);
  相关解决方案