[JavaScript] fnGetQueryStringArgs() - 获取URL访问参数集合.js →→→→→进入此内容的聊天室

来自 , 2019-09-30, 写在 JavaScript, 查看 103 次.
URL http://www.code666.cn/view/2e3d2c4f
  1. // js获取URL访问参数
  2. function fnGetQueryStringArgs() {
  3.     //取得查询字符串并去掉开头的问号
  4.     var qs = ((location.search.length > 0) ? location.search.substring(1) : ""),
  5.         //保存数据的对象,保存键值对格式
  6.         args = {},
  7.         //取得每一项
  8.         items = qs.length ? qs.split("&") : [],
  9.         item = null, name = null, value = null;
  10.  
  11.     //逐个将每一项添加到args对象中
  12.     for (var i = 0; i < items.length; i++) {
  13.         item = items[i].split("=");
  14.         name = decodeURIComponent(item[0]);
  15.         value = decodeURIComponent(item[1]);
  16.         if (name.length) {
  17.             args[name] = value;
  18.         }
  19.     }
  20.     return args;
  21. }

回复 "fnGetQueryStringArgs() - 获取URL访问参数集合.js"

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

captcha