Skip to content

Commit

Permalink
Add option to open external links in new window
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Lyons committed Feb 26, 2015
1 parent bc7a110 commit d271811
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/display/annotation_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 9 additions & 0 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit d271811

Please sign in to comment.