Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ran into the same problem in my rewrite of tarheelreader.org. I'm using History.js and it is working fine except for the refresh issue in IE8. This hack is working for me.</p> <p>In my startup code that only runs on initial page load I do:</p> <pre><code>var url = window.location.href; if (url.indexOf('#') &gt; -1) { // ie refresh hack controller.stateChange(); } </code></pre> <p>where <code>controller.stateChange()</code> is the state change handler I use for all History changes.</p> <pre><code>function stateChange() { // handle changes in the URL var hist = History.getState(), url = hist.url, context = hist.data; renderUrl(url, context).then(function(title) { document.title = title; }); } </code></pre> <p>You can see all the code in main.js and controller.js at <a href="https://github.com/gbishop/TarHeelReaderTheme" rel="nofollow">https://github.com/gbishop/TarHeelReaderTheme</a></p> <p><strong>Edit</strong> Further exploration has lead to a case where History.js uses the initial URL instead of the root. This hack seems to handle that case.</p> <pre><code>function stateChange() { // handle changes in the URL var hist = History.getState(), url = hist.url, bar = window.location.href, context = hist.data; //console.log("State changed...", url, context); if (url != bar &amp;&amp; bar.indexOf('#') &gt; -1) { //console.log('bar = ', bar); // I think we only get here in IE8 // hack for hash mode urls var root = History.getRootUrl(), hashIndex = bar.indexOf('#'); if (root != bar.slice(0, hashIndex)) { // try to fix the url url = root + bar.slice(hashIndex); //console.log('new url =', url); window.location.href = url; } } renderUrl(url, context).then(function(title) { document.title = title; }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload