发现很多人用jquery.query.js,但是这个有bug
下面这个比较好
https://github.com/allmarkedup/jQuery-URL-Parser
/*---- jQuery version -----*/ var url = $.url(); // parse the current page URL var url = $.url('http://allmarkedup.com'); // pass in a URI as a string and parse that var url = $('#myElement').url(); // extract the URL from the selected element and parse that - will work on any element with a `src`, `href` or `action` attribute. /*---- plain JS version -----*/ var url = purl(); // parse the current page URL var url = purl('http://allmarkedup.com'); // pass in a URI as a string and parse that /*---- jQuery version -----*/ $.url('http://allmarkedup.com?sky=blue&grass=green').param('sky'); // returns 'blue' /*---- plain JS version -----*/ purl('http://allmarkedup.com?sky=blue&grass=green').param('sky'); // returns 'blue'
近期评论