js中将URL中的参数提取出来作为对象的实现代码
代码如下: (function() { var urlToObject = function(url) { var urlObject = {}; if (/\?/.test(url)) { var urlString = url.substring(url.indexOf(“?”)+1); var urlArray = urlString.split(“&”); for (var i=0, len=urlArray.length; i<len; i++) { var urlItem = urlArray[i]; var item = urlItem.split(“=”); urlObj
用户评论