The simple <a> IDL-Attribute Decomposition

<a> element to access and modify components of an URL

JavaScript

/*
    The simple <a> URL Mutation "Hack"
    http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#url-decomposition-idl-attributes
 */

function out(a, key) {
    var p = document.createElement("p");
    p.innerHTML = "<strong>" + key + "</strong> "
        + "<code>" + a[key] + "</code> "
        + "<em>" + a.href + "</em>";
    
    document.body.appendChild(p);
}

var a = document.createElement("a");
a.href = location.href;

out(a, "pathname");

a.search = "?foo=bar";
out(a, "search");

// not resolving stuff
a.search = "?foo=bar&&blub=ber";
out(a, "search");

a.pathname = "/world/hello.html";
out(a, "pathname");