title: window.history.pushState refreshing the browser
body: <p>I am working on some javascript code, and using <code>window.History.pushState</code> to load new <code>HTML</code> pages, instead of using <code>href</code> tags. My code (which is <strong>working fine</strong>) looks like this. </p>
  
  <pre><code>window.History.pushState({urlPath:'/page1'},"",'/page1')
  </code></pre>
  
  <p>strangely, this <strong>fails</strong>, ie reloads the browser</p>
  
  <pre><code>window.History.pushState({urlPath:'/page2.php'},"",'/page2.php')
  </code></pre>
  
  <p>But this <strong>works</strong>, content is updated, browser not refreshed ! (notice the URL is absolute and not relative)</p>
  
  <pre><code>window.History.pushState({urlPath:'www.domain.com/page2.php'},"",'www.domain.com/page2.php')
  </code></pre>
  
  <p>The <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history">documentation</a> for <code>window.History.pushState</code> says that the third parameter URL can be either absolute or relative - </p>
  
  <blockquote>
    <p>URL — The new history entry's URL is given by this parameter. Note
    that the browser won't attempt to load this URL after a call to
    pushState(), but it might attempt to load the URL  later, for instance
    after the user restarts the browser. The new URL does not need to be 
    absolute; if it's relative, it's resolved relative to the current URL.
    The new URL must be  of the same origin as the current URL; otherwise,
    pushState() will throw an exception.  This parameter is optional; if
    it isn't specified, it's set to the document's current URL.</p>
  </blockquote>
  
  <p>Absolute URLs seem to be working but relative seem to be not. Why is this happening?</p>