by dbloom · 14y ago · 0 comments
var temp = document.createElemenet('a');
temp.href = 'http://www.google.com/search?q=foo#blah;
alert(temp.hostname); // www.google.com
alert(temp.hash); // #blah
alert(temp.protocol); // http:
alert(temp.search); // ?q=foo
temp.search = '?q=baz';
alert(temp.href); // http://www.google.com/search?q=baz#blah
// assuming this is running on http://www.example.com:
temp.href = '/asdf.html';
alert(temp.href); // http://www.example.com/asdf.htmlDoes the IDL stuff work in non-browser Javascript (like node.js)?
URI.js could be really useful for developers building web apps that need to do a lot of URL parsing or manipulation. But developers who only need basic functionality outside of performance-critical loops would probably be better off using built-in functionality.