Home  >  Article  >  Web Front-end  >  javascript使用location.search的示例_javascript技巧

javascript使用location.search的示例_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:17:321106browse
复制代码 代码如下:

function GetRequest() {    
    var url = location.search; //获取url中"?"符后的字串    
    var theRequest = new Object();    
    if (url.indexOf("?") != -1) {       
        var str = url.substr(1);       
        strs = str.split("&");       
        for(var i = 0; i             theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;

  var Request = new Object();
  Request = GetRequest();
    var 参数1,参数2,参数3,参数N;
    参数1 = Request['参数1'];
    参数2 = Request['参数2'];
    参数3 = Request['参数3'];
    参数N = Request['参数N'];
   
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn