美文网首页
获取url中"?"符后的字符串并正则匹配

获取url中"?"符后的字符串并正则匹配

作者: 程序猿吴彦祖 | 来源:发表于2017-03-28 17:55 被阅读0次

    function GetQueryString(name) {

    varreg=newRegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");

    varr=window.location.search.substr(1).match(reg);  //获取url中"?"符后的字符串并正则匹配

    varcontext="";

    if (r != null)

    context=r[2];

    reg=null;

    r=null;

    returncontext== null ||context== "" ||context== "undefined" ? "" : context;

    相关文章

      网友评论

          本文标题:获取url中"?"符后的字符串并正则匹配

          本文链接:https://www.haomeiwen.com/subject/eixsottx.html