• 请不要在回答技术问题时复制粘贴 AI 生成的内容
fishg
V2EX  ›  程序员

javascript获取querystring参数值

  •  
  •   fishg · May 6, 2013 · 3835 views
    This topic created in 4767 days ago, the information mentioned may be changed or developed.
    queryString = function (fieldName) {
    var urlString = document.location.search||'';
    var r=new RegExp('(&|\\?)'+fieldName+'=(.*?)(&|$)');
    return urlString.match(r)?decodeURIComponent(urlString.match(r)[2]):null;
    }
    3 replies    1970-01-01 08:00:00 +08:00
    explon
        1
    explon  
       May 6, 2013
    为什么使用 hash
    explon
        2
    explon  
       May 6, 2013   ❤️ 1
    (!修正)为什么不使用 hash
    fishg
        3
    fishg  
    OP
       May 6, 2013
    用不用hash是另外一回事了吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5988 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 03:08 · PVG 11:08 · LAX 20:08 · JFK 23:08
    ♥ Do have faith in what you're doing.