-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to open external links in new window #5758
Conversation
@@ -217,6 +217,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { | |||
|
|||
var link = document.createElement('a'); | |||
link.href = link.title = item.url || ''; | |||
if (PDFJS.openExternalLinksInNewWindow) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this set target = '_blank'
for both external and internal links, when the condition is true
? You probably need to do something along these lines instead:
if (item.url && PDFJS.openExternalLinksInNewWindow) {
029bb5f
to
d271811
Compare
@Snuffleupagus - I didn't realize internal links would hit this codepath but make sense and added the url check. FWIW, when I created a link to another page (in Acrobat XI) it correctly jumped to the page even without this check, put perhaps this wasn't an "internal link"? |
If you look at annotations_layer_builder.js#L103, you will see that all links are fetched in the same way by the viewer code. Further down, at annotations_layer_builder.js#L126, you'll see the difference between the way internal/external links are handled. With the current way that internal destinations are implemented, your first patch "worked" correctly more or less by accident :-) |
Cool, totally make sense! Is there anything else for me to do? Not trying to be pushy, rather, I haven't contributed to pdf.js before and want to make sure you're not waiting on me =) |
This seems fine to me; but given that adding a configuration option usually means that you'll have to support it forever, I figured it would be a good idea for one of the devs to sign off on this. /cc @yurydelendik, @brendandahl Any feedback on this PR? |
yeah, eventually we have to move those properties for stateless objects. we can keep that where it is, but in the future add migration path to default those objects properties to set values from obsolete properties in the PDFJS. Just a reminder for users of such properties to set them once before getDocument is invoked, to avoid confusion in the future. Thanks for the patch. |
Add option to open external links in new window
Add option to open external links in new window
This change adds a PDFJS.openExternalLinkInNewWindow boolean, which opens links in a new window when enabled. The default now and previous to this change, clicking on an external link will open the link the same window (and navigate away from PDF.js).