最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What would be an alternative for window.URL in IE? - Stack Overflow

programmeradmin2浏览0评论

I'm now using window.URL object to work with url:

var url = new window.URL(text);
return url.host + url.pathname;

but it looks like IE does not pletely support it.

What universal solution could you remend?

I'm now using window.URL object to work with url:

var url = new window.URL(text);
return url.host + url.pathname;

but it looks like IE does not pletely support it.

What universal solution could you remend?

Share Improve this question asked Mar 3, 2016 at 9:26 Stepan SuvorovStepan Suvorov 26.3k27 gold badges115 silver badges178 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 2

I use parseURI.js by Steven Levithan: http://blog.stevenlevithan./archives/parseuri

It's small but prehensive. To use it to do the same job as your snippet:

var url = parseUri(text);
return url.host + url.path;

I use this one as a backup for IE, this is an implementation of w3c specs maintained by PolymerJS https://github./webponents/URL

发布评论

评论列表(0)

  1. 暂无评论