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

javascript获取querystring参数值

  •  
  •   fishg · May 6, 2013 · 4257 views
    This topic created in 4940 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
    explon
    May 6, 2013
    1
    为什么使用 hash
    explon
    explon
    May 6, 2013❤️1
    2
    (!修正)为什么不使用 hash
    fishg
    fishg
    OP
    May 6, 2013
    3
    用不用hash是另外一回事了吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1807 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:58 · PVG 12:58 · LAX 20:58 · JFK 23:58
    ♥ Do have faith in what you're doing.