From 5c93ec3a2c2e3c2a9f67cc1d78faae7e2233720f Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 24 Jun 2013 20:46:13 +0200 Subject: [PATCH] Check if the browser supports manipulation of the history --- web/compatibility.js | 9 ++++++++- web/viewer.js | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/web/compatibility.js b/web/compatibility.js index 99534efb3..b6a9fb2b3 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -391,7 +391,7 @@ if (typeof PDFJS === 'undefined') { }); })(); -// Check console compatability +// Check console compatibility (function checkConsoleCompatibility() { if (!('console' in window)) { window.console = { @@ -455,3 +455,10 @@ if (typeof PDFJS === 'undefined') { PDFJS.disableRange = true; } })(); + +// Check if the browser supports manipulation of the history. +(function checkHistoryManipulation() { + if (!window.history.pushState) { + PDFJS.disableHistory = true; + } +})(); diff --git a/web/viewer.js b/web/viewer.js index 62848292c..87de9fa88 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -31,7 +31,6 @@ var VERTICAL_PADDING = 5; var MIN_SCALE = 0.25; var MAX_SCALE = 4.0; var SETTINGS_MEMORY = 20; -var HISTORY_DISABLED = false; var SCALE_SELECT_CONTAINER_PADDING = 8; var SCALE_SELECT_PADDING = 22; var RenderingStates = { @@ -190,7 +189,7 @@ var PDFHistory = { initialDestination: null, initialize: function pdfHistoryInitialize(fingerprint) { - if (HISTORY_DISABLED || window.parent !== window) { + if (PDFJS.disableHistory || window.parent !== window) { // The browsing history is only enabled when the viewer is standalone, // i.e. not when it is embedded in a page. return; @@ -2564,6 +2563,10 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) { PDFJS.disableFontFace = (hashParams['disableFontFace'] === 'true'); } + if ('disableHistory' in hashParams) { + PDFJS.disableHistory = (hashParams['disableHistory'] === 'true'); + } + //#if !(FIREFOX || MOZCENTRAL) var locale = navigator.language; if ('locale' in hashParams)