zoukankan      html  css  js  c++  java
  • 获取url传的参数转变为对象的方法

    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 < strs.length; i ++) { 
    theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); 
    } 
    } 
    return theRequest; 
    } 
    调用方法: 
    <Script language="javascript"> 
    var Request = new Object(); 
    Request = GetRequest(); 
    console.log(Request );
    var 参数1,参数2,参数3,参数N; 
    参数1 = Request['参数1']; 
    参数2 = Request['参数2']; 
    参数3 = Request['参数3']; 
    参数N = Request['参数N']; 
    </Script>

    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 < strs.length; i ++) { 
    theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); 
    } 
    } 
    return theRequest; 
    }

  • 相关阅读:
    poj 2312 Battle City
    poj 2002 Squares
    poj 3641 Pseudoprime numbers
    poj 3580 SuperMemo
    poj 3281 Dining
    poj 3259 Wormholes
    poj 3080 Blue Jeans
    poj 3070 Fibonacci
    poj 2887 Big String
    poj 2631 Roads in the North
  • 原文地址:https://www.cnblogs.com/wei-dong/p/7273782.html
Copyright © 2011-2022 走看看