Check if the browser supports manipulation of the history

This commit is contained in:
Jonas 2013-06-24 20:46:13 +02:00
parent cce3e9cd1b
commit 5c93ec3a2c
2 changed files with 13 additions and 3 deletions

View File

@ -391,7 +391,7 @@ if (typeof PDFJS === 'undefined') {
}); });
})(); })();
// Check console compatability // Check console compatibility
(function checkConsoleCompatibility() { (function checkConsoleCompatibility() {
if (!('console' in window)) { if (!('console' in window)) {
window.console = { window.console = {
@ -455,3 +455,10 @@ if (typeof PDFJS === 'undefined') {
PDFJS.disableRange = true; PDFJS.disableRange = true;
} }
})(); })();
// Check if the browser supports manipulation of the history.
(function checkHistoryManipulation() {
if (!window.history.pushState) {
PDFJS.disableHistory = true;
}
})();

View File

@ -31,7 +31,6 @@ var VERTICAL_PADDING = 5;
var MIN_SCALE = 0.25; var MIN_SCALE = 0.25;
var MAX_SCALE = 4.0; var MAX_SCALE = 4.0;
var SETTINGS_MEMORY = 20; var SETTINGS_MEMORY = 20;
var HISTORY_DISABLED = false;
var SCALE_SELECT_CONTAINER_PADDING = 8; var SCALE_SELECT_CONTAINER_PADDING = 8;
var SCALE_SELECT_PADDING = 22; var SCALE_SELECT_PADDING = 22;
var RenderingStates = { var RenderingStates = {
@ -190,7 +189,7 @@ var PDFHistory = {
initialDestination: null, initialDestination: null,
initialize: function pdfHistoryInitialize(fingerprint) { 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, // The browsing history is only enabled when the viewer is standalone,
// i.e. not when it is embedded in a page. // i.e. not when it is embedded in a page.
return; return;
@ -2564,6 +2563,10 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
PDFJS.disableFontFace = (hashParams['disableFontFace'] === 'true'); PDFJS.disableFontFace = (hashParams['disableFontFace'] === 'true');
} }
if ('disableHistory' in hashParams) {
PDFJS.disableHistory = (hashParams['disableHistory'] === 'true');
}
//#if !(FIREFOX || MOZCENTRAL) //#if !(FIREFOX || MOZCENTRAL)
var locale = navigator.language; var locale = navigator.language;
if ('locale' in hashParams) if ('locale' in hashParams)