diff --git a/src/display/annotation_helper.js b/src/display/annotation_helper.js index 323617657a713..a64ee35f78291 100644 --- a/src/display/annotation_helper.js +++ b/src/display/annotation_helper.js @@ -217,6 +217,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { var link = document.createElement('a'); link.href = link.title = item.url || ''; + if (item.url && PDFJS.openExternalLinksInNewWindow) { + link.target = '_blank'; + } container.appendChild(link); diff --git a/src/display/api.js b/src/display/api.js index 547fe6d8a1a9d..7cd8c57736e0a 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -160,6 +160,15 @@ PDFJS.verbosity = (PDFJS.verbosity === undefined ? PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? 16777216 : PDFJS.maxCanvasPixels); +/** + * Opens external links in a new window if enabled. The default behavior opens + * external links in the PDF.js window. + * @var {boolean} + */ +PDFJS.openExternalLinksInNewWindow = ( + PDFJS.openExternalLinksInNewWindow === undefined ? + false : PDFJS.openExternalLinksInNewWindow); + /** * Document initialization / loading parameters object. *