diff --git a/web/base_viewer.js b/web/base_viewer.js index 9d7ac1d71c5c3..36c63cba07a3d 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -145,14 +145,21 @@ class BaseViewer { this.viewer = options.viewer || options.container.firstElementChild; if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || GENERIC")) && - !( - this.container instanceof HTMLDivElement && - this.viewer instanceof HTMLDivElement - ) + typeof PDFJSDev === "undefined" || + PDFJSDev.test("!PRODUCTION || GENERIC") ) { - throw new Error("Invalid `container` and/or `viewer` option."); + if ( + !( + this.container instanceof HTMLDivElement && + this.viewer instanceof HTMLDivElement + ) + ) { + throw new Error("Invalid `container` and/or `viewer` option."); + } + + if (getComputedStyle(this.container).position !== "absolute") { + throw new Error("The `container` must be absolutely positioned."); + } } this.eventBus = options.eventBus; this.linkService = options.linkService || new SimpleLinkService();