[whatwg] Document's base URI should use the document's *current* address

Justin Lebar justin.lebar at gmail.com
Wed Feb 22 04:11:17 PST 2012


> From an author's point of view, there's no such thing as the
> document's original URI and, unless you're a nerd, you've never heard
> of the base URI.  There's just the document's URI, modified by
> pushState.
>
> From this point of view, I'd say it's less surprising that relative
> URIs would break when you change directories (hey, you *asked* for it)
> than that anchor refs would update the browser's address bar and
> document.location relative to the old URI.

In my tests, Chrome and Firefox both immediately change
document.baseURL when you call pushState.  Images (and I presume other
resources) are resolved relative to the new base.

I'm not sure why your earlier test with seemed to "work" in Chrome, Hixie.  :-/

I think this ship may have sailed.

-Justin

<button onclick='push()'>Click me</button>
function push() {
  history.pushState('', '', '/' + Math.random() + '/file');
  alert(document.baseURI);
}



More information about the whatwg mailing list