Get escaped URL parameter

后端 未结 19 2683
小蘑菇
小蘑菇 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:11

    $.urlParam = function(name){
      var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(top.window.location.href); 
      return (results !== null) ? results[1] : 0;
    }
    
    $.urlParam("key");
    

提交回复
热议问题