diff --git a/lib/ComicBook.js b/lib/ComicBook.js index bf20176..958e239 100644 --- a/lib/ComicBook.js +++ b/lib/ComicBook.js @@ -66,7 +66,16 @@ function ComicBook(id, srcs, opts) { // the current page, can pass a default as a url hash var pointer = (parseInt(location.hash.substring(1),10) - 1) || 0; - + + // enables the back button by tracking any url hash changes and loading the correct page. + setInterval(function() { + var hash = parseInt(location.hash.substring(1),10) - 1; + if (hash !== pointer) { + pointer = hash; + ComicBook.prototype.draw(); + } + }, 300); + /** * Figure out the cursor position relative to the canvas. *