Get escaped URL parameter

后端 未结 19 2958
小蘑菇
小蘑菇 2020-11-21 13:41

I\'m looking for a jQuery plugin that can get URL parameters, and support this search string without outputting the JavaScript error: \"malformed URI sequence\". If there is

19条回答
  •  甜味超标
    2020-11-21 14:08

    Need to add the i parameter to make it case insensitive:

      function getURLParameter(name) {
        return decodeURIComponent(
          (RegExp(name + '=' + '(.+?)(&|$)', 'i').exec(location.search) || [, ""])[1]
        );
      }
    

提交回复
热议问题