New tab Hyperlink in PDF

I noticed that if I create a hyperlink to a PDF with target="_blank"

, it doesn't open correctly. It opens a new tab but doesn't load the PDF, it just shows a white screen. I am using Google Chrome v.43. Has anyone else noticed this problem or found a fix?

I've tested this with Safari and Firefox and both have no problem opening PDFs to a new tab. I've also tried disabling my add-ons in Chrome and using Incognito mode with no luck.

Test link: http://jsfiddle.net/fkfxoho0/

<a href="http://static.googleusercontent.com/media/www.google.com/en/us/webmasters/docs/search-engine-optimization-starter-guide.pdf" target="_blank">Optimization Starter Guide</a>

      

Chrome video v.42 and then v.43 issue:
https://youtu.be/v_EAedODKfA

+3


source to share


1 answer


The problem comes from iframes with an attributesandbox

(like JSFiddle), as this problem does not occur with links outside of such frames. The problem can be reproduced outside the JSFiddle with the following HTML files.

frame.html

<iframe sandbox="allow-same-origin allow-forms allow-popups allow-scripts" src="content.html"></iframe>

      

content.html

<a href="https://www.adobe.com/enterprise/accessibility/pdfs/acro6_cg_ue.pdf">default</a>
<a href="https://www.adobe.com/enterprise/accessibility/pdfs/acro6_cg_ue.pdf" target="_blank">_blank</a>
<a href="https://www.adobe.com/enterprise/accessibility/pdfs/acro6_cg_ue.pdf" target="_top">_top</a>

      

With these values the sandbox default target, _blank

and _top

things can not display PDF, in this case the default does not appear in, iframe, and _blank

and _top

opens a new tab that ( _top

opens a new tab because of the sandbox).

If we add a sandbox value allow-top-navigation

, we can make it _top

work as expected.

<iframe sandbox="allow-same-origin allow-top-navigation allow-forms allow-popups allow-scripts" src="content.html"></iframe>

      

However, a new tab that is open _blank

still does not render the PDF. Even if I add all the sandbox mitigation properties on MDN, the problem is still present (not what I expected to be added allow-pointer-lock

to do anything).



<iframe sandbox="allow-same-origin allow-top-navigation allow-forms allow-popups allow-scripts allow-pointer-lock" src="content.html"></iframe>

      

The only way to get it _blank

to work inside an iframe in Chrome 43 is to remove the attribute entirely sandbox

.

<iframe src="content.html"></iframe>

      

The target is now the default, _blank

and _top

works as expected.

Unfortunately, removing the attribute is sandbox

not a workaround. If you are using it in the first place, you will probably need it. I can't say for sure that there is no protection to block PDFs in a sandboxed iframe, but the user experience from this leads me to believe that this is most likely a bug.

I opened a bug report for this issue by referencing this question:

https://code.google.com/p/chromium/issues/detail?id=505860

UPDATE: . It turns out it's a built-in security feature, so it probably won't revert to Chrome 42's behavior, but a new sandbox option may be added in the future to relax this security feature.

+2


source







All Articles