Skip to content

Instantly share code, notes, and snippets.

@dfang
Created September 25, 2012 10:33
Show Gist options
  • Save dfang/3781096 to your computer and use it in GitHub Desktop.
Save dfang/3781096 to your computer and use it in GitHub Desktop.
get url params
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
@dfang
Copy link
Author

dfang commented Sep 25, 2012

(function($) {
$.QueryString = (function(a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i)
{
var p=a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/+/g, " "));
}
return b;
})(window.location.search.substr(1).split('&'))
})(jQuery);

http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values/901144#901144

@dfang
Copy link
Author

dfang commented Sep 25, 2012

jQuery 判断空对象的方法
isEmptyObject
var obj = { };
var arr = [];

$.isEmptyObject(obj); => true
$.isEmptyObject(arr); => true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment