$.query.get("id")

jquery.params.js代码

/**
* jQuery.query - Query String Modification and Creation for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/8/13
*
* @author Blair Mitchelmore
* @version 2.1.7
*
**/
new function (settings) {
// Various Settings
var $separator = settings.separator || '&';
var $spaces = settings.spaces === false ? false : true;
var $suffix = settings.suffix === false ? '' : '[]';
var $prefix = settings.prefix === false ? false : true;
var $hash = $prefix ? settings.hash === true ? "#" : "?" : "";
var $numbers = settings.numbers === false ? false : true; jQuery.query = new function () {
var is = function (o, t) {
return o != undefined && o !== null && (!!t ? o.constructor == t : true);
};
var parse = function (path) {
var m, rx = /\[([^[]*)\]/g, match = /^([^[]+)(\[.*\])?$/.exec(path), base = match[1], tokens = [];
while (m = rx.exec(match[2])) tokens.push(m[1]);
return [base, tokens];
};
var set = function (target, tokens, value) {
var o, token = tokens.shift();
if (typeof target != 'object') target = null;
if (token === "") {
if (!target) target = [];
if (is(target, Array)) {
target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
} else if (is(target, Object)) {
var i = 0;
while (target[i++] != null);
target[--i] = tokens.length == 0 ? value : set(target[i], tokens.slice(0), value);
} else {
target = [];
target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
}
} else if (token && token.match(/^\s*[0-9]+\s*$/)) {
var index = parseInt(token, 10);
if (!target) target = [];
target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
} else if (token) {
var index = token.replace(/^\s*|\s*$/g, "");
if (!target) target = {};
if (is(target, Array)) {
var temp = {};
for (var i = 0; i < target.length; ++i) {
temp[i] = target[i];
}
target = temp;
}
target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
} else {
return value;
}
return target;
}; var queryObject = function (a) {
var self = this;
self.keys = {}; if (a.queryObject) {
jQuery.each(a.get(), function (key, val) {
self.SET(key, val);
});
} else {
jQuery.each(arguments, function () {
var q = "" + this;
q = q.replace(/^[?#]/, ''); // remove any leading ? || #
q = q.replace(/[;&]$/, ''); // remove any trailing & || ;
if ($spaces) q = q.replace(/[+]/g, ' '); // replace +'s with spaces jQuery.each(q.split(/[&;]/), function () {
var key = decodeURIComponent(this.split('=')[0] || "");
var val = decodeURIComponent(this.split('=')[1] || ""); if (!key) return; if ($numbers) {
if (/^[+-]?[0-9]+\.[0-9]*$/.test(val)) // simple float regex
val = parseFloat(val);
else if (/^[+-]?[0-9]+$/.test(val)) // simple int regex
val = parseInt(val, 10);
} val = (!val && val !== 0) ? true : val; if (val !== false && val !== true && typeof val != 'number')
val = val; self.SET(key, val);
});
});
}
return self;
}; queryObject.prototype = {
queryObject: true,
has: function (key, type) {
var value = this.get(key);
return is(value, type);
},
GET: function (key) {
if (!is(key)) return this.keys;
var parsed = parse(key), base = parsed[0], tokens = parsed[1];
var target = this.keys[base];
while (target != null && tokens.length != 0) {
target = target[tokens.shift()];
}
return typeof target == 'number' ? target : target || "";
},
get: function (key) {
var target = this.GET(key);
if (is(target, Object))
return jQuery.extend(true, {}, target);
else if (is(target, Array))
return target.slice(0);
return target;
},
SET: function (key, val) {
var value = !is(val) ? null : val;
var parsed = parse(key), base = parsed[0], tokens = parsed[1];
var target = this.keys[base];
this.keys[base] = set(target, tokens.slice(0), value);
return this;
},
set: function (key, val) {
return this.copy().SET(key, val);
},
REMOVE: function (key) {
return this.SET(key, null).COMPACT();
},
remove: function (key) {
return this.copy().REMOVE(key);
},
EMPTY: function () {
var self = this;
jQuery.each(self.keys, function (key, value) {
delete self.keys[key];
});
return self;
},
load: function (url) {
var hash = url.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
var search = url.replace(/^.*?[?](.+?)(?:#.+)?$/, "$1");
return new queryObject(url.length == search.length ? '' : search, url.length == hash.length ? '' : hash);
},
empty: function () {
return this.copy().EMPTY();
},
copy: function () {
return new queryObject(this);
},
COMPACT: function () {
function build(orig) {
var obj = typeof orig == "object" ? is(orig, Array) ? [] : {} : orig;
if (typeof orig == 'object') {
function add(o, key, value) {
if (is(o, Array))
o.push(value);
else
o[key] = value;
}
jQuery.each(orig, function (key, value) {
if (!is(value)) return true;
add(obj, key, build(value));
});
}
return obj;
}
this.keys = build(this.keys);
return this;
},
compact: function () {
return this.copy().COMPACT();
},
toString: function () {
var i = 0, queryString = [], chunks = [], self = this;
var encode = function (str) {
str = str + "";
if ($spaces) str = str.replace(/ /g, "+");
return encodeURIComponent(str);
};
var addFields = function (arr, key, value) {
if (!is(value) || value === false) return;
var o = [encode(key)];
if (value !== true) {
o.push("=");
o.push(encode(value));
}
arr.push(o.join(""));
};
var build = function (obj, base) {
var newKey = function (key) {
return !base || base == "" ? [key].join("") : [base, "[", key, "]"].join("");
};
jQuery.each(obj, function (key, value) {
if (typeof value == 'object')
build(value, newKey(key));
else
addFields(chunks, newKey(key), value);
});
}; build(this.keys); if (chunks.length > 0) queryString.push($hash);
queryString.push(chunks.join($separator)); return queryString.join("");
}
}; return new queryObject(location.search, location.hash);
};
} (jQuery.query || {}); // Pass in jQuery.query as settings object

html页面间传递参数的更多相关文章

  1. jsp页面间传递参数 中文乱码问题(zz)

      jsp页面间传递参数 中文乱码问题 1.传递参数 var url = "*****Test.jsp?param1="+encodeURI(encodeURI(str));//对 ...

  2. ios页面间传递参数四种方式

    ios页面间传递参数四种方式 1.使用SharedApplication,定义一个变量来传递. 2.使用文件,或者NSUserdefault来传递 3.通过一个单例的class来传递 4.通过Dele ...

  3. JSP页面间传递参数的5种方法

    JSP页面间传递参数是经常需要使用到的功能,有时还需要多个JSP页面间传递参数.下面介绍一下实现的方法. (1)直接在URL请求后添加 如:< a href="thexuan.jsp? ...

  4. jsp 页面间传递参数

    JSP页面间传递参数是经常需要使用到的功能,有时还需要多个JSP页面间传递参数.下面介绍一下实现的方法. (1)直接在URL请求后添加 如:< a href="thexuan.jsp? ...

  5. .net中常用的几种页面间传递参数的方法

    转自:http://www.cnblogs.com/lxshanye/archive/2013/04/11/3014207.html 参考:http://www.cnblogs.com/zhangka ...

  6. ionic3+angular5页面间传递参数

    一.从一个页面跳转到另一个页面的方法 1.引入服务 import { NavController } from 'ionic-angular'; 2.初始化 constructor(public na ...

  7. javascript页面间传递参数

    1.通过URL传递参数 传递参数页 function setCity() { var str = document.getElementById("cityName"); if ( ...

  8. react页面间传递参数

    react-router页面跳转,带请求参数 this.context.router.push({pathname:'/car_datail',state:{item:"hello" ...

  9. ionic1页面间传递参数的问题

    1.  $scope.routeinfo是我要传递的参数--到scheddulcontent这个页面去: $state.go( "scheddulcontent" , { 'rou ...

  10. ASP.NET 页面间传递参数的方法

    http://www.cnblogs.com/eoiioe/archive/2008/04/08/1142247.html

随机推荐

  1. git lock fail解决

    本地多个分支,remote .remote tracking.local checkout了2个不同版本分支,发现最后版本却是相同的,然后pull时报git lock fail, 看来发送了冲突了,删 ...

  2. SICP 笔记:环境配置

    SICP 笔记:环境配置 记录学习<算机的程序的构造和解释>的笔记. 环境配置 SICP 里面使用的语言是一种 Lisp 的变体 Scheme. 使用 DrRacket 作为 IDE 来进 ...

  3. css动画-滚动通知

    使用动画 <div class="horNotice"> <div class="horMove"> <span>累计87例 ...

  4. 设置Redhat终端显示中文

    修改.bash_profile,增加: export LC_ALL= export LANG=C source .bash_profile

  5. uniapp APP端 跳转微信小程序 完成微信支付功能,并回跳回来

    先保存   参考链接    完成功能在做具体记录 https://blog.csdn.net/qq_40146789/article/details/121262700?spm=1001.2101.3 ...

  6. 6.配置git-码云仓库

    使用git需要使用码云或者github,github存在访问慢的情况,所以我使用码云(gitee). git客户端 下载安装 到git官网  https://git-scm.com/ 下载git客户端 ...

  7. vue中key

    使用key维护列表的状态 当列表的数据变化时,默认情况下,vue尽可能的服用已存在的DOM元素,从而提升渲染的性能.但这种默认的性能优化策略,会导致由状态的列表无法被正确更新. key的使用注意事项: ...

  8. 使用vue3在element plus中在el-table中拖拽

    1.安装 vuedraggable npm i -S vuedraggable 2.在使用的组件,引入.sortablejs包含在vuedraggable import Sortable from & ...

  9. 动画图解 Git 的 10 大命令

    原文地址:https://dev.to/lydiahallie/cs-visualized-useful-git-commands-37p1 原文作者:Lydia Hallie 前言 尽管 Git 是 ...

  10. vue3 微信支付和支付宝支付 H5和微信内置浏览器

    vue3微信支付和支付宝支付 // 判断是否为微信内置浏览器 let browser: any = navigator.userAgent.toLowerCase(); let isWechat: a ...