利用a标签自动解析URL
2014-07-02 14:11
260 查看
function parseURL(url) { var a = document.createElement('a'); a.href = url; return { source: url, protocol: a.protocol.replace(':',''), host: a.hostname, port: a.port, query: a.search, params: (function(){ var ret = {}, seg = a.search.replace(/^\?/,'').split('&'), len = seg.length, i = 0, s; for (;i<len;i++) { if (!seg[i]) { continue; } s = seg[i].split('='); ret[s[0]] = s[1]; } return ret; })(), file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1], hash: a.hash.replace('#',''), path: a.pathname.replace(/^([^\/])/,'/$1'), relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [,''])[1], segments: a.pathname.replace(/^\//,'').split('/') }; }
相关文章推荐
- 利用a标签自动解析URL
- js利用a标签自动解析URL
- 利用a标签自动解析URL
- 利用a标签自动解析URL
- 利用a标签自动解析URL分析网址实例
- Javascript 利用a标签自动解析URL分析网址实例
- 利用a标签自动解析URL
- 利用a标签自动解析URL
- 利用a标签自动解析URL
- 【javascript】利用 a 标签自动解析 url
- 利用a标签自动解析URL
- 利用a标签自动解析URL
- a标签自动解析URL
- 利用a标签解析URL
- 利用a标签解析url
- 利用反射和标签自动解析游戏配置
- 想要页面自动解析从数据库获得的数据中的html标签的方法
- 利用a标签特性解析地址(附加属性说明)
- 利用Pornzilla扩展的小书签功能基于URL中数字自动批量生成URL