diff --git a/web/pdf_history.js b/web/pdf_history.js index c85954ede..86874f786 100644 --- a/web/pdf_history.js +++ b/web/pdf_history.js @@ -65,8 +65,7 @@ var PDFHistory = { // is opened in the web viewer. this.reInitialized = true; } - window.history.replaceState({ fingerprint: this.fingerprint }, '', - document.URL); + this._pushOrReplaceState({ fingerprint: this.fingerprint }, true); } var self = this; @@ -131,6 +130,21 @@ var PDFHistory = { state.target && state.target.hash) ? true : false; }, + _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj, + replace) { + // In Firefox, 'urlParam' needs to be undefined in order to prevent issues + // when local files are opened. + var urlParam; +//#if (GENERIC || CHROME) + urlParam = document.URL; +//#endif + if (replace) { + window.history.replaceState(stateObj, '', urlParam); + } else { + window.history.pushState(stateObj, '', urlParam); + } + }, + get isHashChangeUnlocked() { if (!this.initialized) { return true; @@ -291,11 +305,8 @@ var PDFHistory = { this._pushToHistory(previousParams, false, replacePrevious); } } - if (overwrite || this.uid === 0) { - window.history.replaceState(this._stateObj(params), '', document.URL); - } else { - window.history.pushState(this._stateObj(params), '', document.URL); - } + this._pushOrReplaceState(this._stateObj(params), + (overwrite || this.uid === 0)); this.currentUid = this.uid++; this.current = params; this.updatePreviousBookmark = true;