parsequery.js 858 B

12345678910111213141516171819202122
  1. jQuery.parseQuery = function(qs) {
  2. var q = (typeof qs === 'string' ? qs : window.location.search);
  3. var ret = [];
  4. q.replace(/#.*$/,'');
  5. q.replace(/([^?&=]+)=?([^&]*)(?:&+|$)/g, function(match, key, value) {
  6. ret.push( { 'name': decodeURIComponent(key.replace(/\+/g,' ')), 'value': decodeURIComponent(value.replace(/\+/g,' ')) });
  7. });
  8. return ret;
  9. }
  10. jQuery.parseQuerySimple = function(querystring) {
  11. var q = jQuery.parseQuery(querystring);
  12. var ret = {};
  13. jQuery.each(q,function(k,v){
  14. ret[v.name] = v.value;
  15. });
  16. return ret;
  17. }
  18. jQuery.parseFragment = function(querystring) {
  19. return window.location.hash;
  20. }