Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use location.replace for URL changes to fix back-button problems.

By using location.replace instead of location.hash to update the URL a
new history entry is not created, so the back button will now behave
as the user expects an return to the page before the bookreader.

This should work for IE and Firefox, but apparantly may not for WebKit
based browsers, as location.replace behaves differently for them.  See
these reported WebKit bugs:

https://bugs.webkit.org/show_bug.cgi?id=20355
https://bugs.webkit.org/show_bug.cgi?id=20425
https://bugs.webkit.org/show_bug.cgi?id=22224

This fix (at least partially) addresses these GnuBook bugs:

https://bugs.launchpad.net/gnubook/+bug/300521
https://bugs.launchpad.net/gnubook/+bug/294281
https://bugs.launchpad.net/gnubook/+bug/272022
  • Loading branch information...
commit 7858770c9a3d34a7c7f86bd2b92a646e11d2b944 1 parent bb42179
Alex Osborne authored February 14, 2009

Showing 1 changed file with 2 additions and 2 deletions. Show diff stats Hide diff stats

  1. 4  GnuBook/GnuBook.js
4  GnuBook/GnuBook.js
@@ -222,7 +222,7 @@ GnuBook.prototype.drawLeafsOnePage = function() {
222 222
     }
223 223
 
224 224
     var firstLeafToDraw  = leafsToDisplay[0];
225  
-    window.location.hash = firstLeafToDraw;    
  225
+    window.location.replace('#' + firstLeafToDraw);
226 226
     this.firstIndex      = firstLeafToDraw;
227 227
 
228 228
     if ((0 != firstLeafToDraw) && (1 < this.reduce)) {
@@ -381,7 +381,7 @@ GnuBook.prototype.updatePageNumBox2UP = function() {
381 381
     } else {
382 382
         $("#GBpagenum").val('');
383 383
     }
384  
-    window.location.hash = this.currentLeafL; 
  384
+    window.location.replace('#' + this.currentLeafL); 
385 385
 }
386 386
 
387 387
 // loadLeafs()

0 notes on commit 7858770

Please sign in to comment.
Something went wrong with that request. Please try again.