Stepan Suvorov Stepan Suvorov -4 years ago 36
Javascript Question

What would be an alternative for window.URL in IE?

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 completely support it.

What universal solution could you recommend?

Answer Source

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

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

var url = parseUri(text);
return url.host + url.path;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download