[JavaScript] JavaScript解析url参数为数据字典 →→→→→进入此内容的聊天室

来自 , 2019-06-19, 写在 JavaScript, 查看 153 次.
URL http://www.code666.cn/view/a11da6bd
  1. /*
  2. It's a simple function to get the URL params,
  3. you can send the URL within the method parameters
  4. or you can use 'window.location.href' to get the actual URL.
  5.  
  6. Obs: This only works for all the URL, if you just want to
  7. send the params (after the '?'), you have to send a '?' before the params.
  8. */
  9.  
  10. function getUrlParams(url) {
  11.   var params = {};
  12.  
  13.   url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str, key, value) {
  14.     params[key] = value;
  15.   });
  16.  
  17.   return params;
  18. }
  19. //javascript/5316

回复 "JavaScript解析url参数为数据字典"

这儿你可以回复上面这条便签

captcha