diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee index ae9421cef3..fe7ea3d427 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee @@ -441,11 +441,11 @@ define [ return true _hasSelection = () -> - selection = window.getSelection() + selection = window.getSelection?() # check the selection type in preference to using # selection.toString() as the latter is "" when the # selection is hidden (e.g. while viewing logs) - return _isSelectionWithinPDF(selection) and selection.type is 'Range' + return selection? and _isSelectionWithinPDF(selection) and selection.type is 'Range' _isSelectionWithinPDF = (selection) -> if selection.rangeCount == 0