WebKit HTML Anchor download attribute ignored by PDF files

When trying to create an anchor with the download attribute it does not work for PDF files, it displays the files inline.

Also when the download attribute is set the target attribute is ignored too.

The tag: <a href="...." download="...." target="_blank">...</a>

The behavior: It displaies the file in line.

The correct behavior: The file should be downloaded and not displayed or at least displayed but with the "_blank" target (new tab).

This is an issue when working with WebSockets which is closed when the file is opened inline.

For that kind of advanced behaviour, you'll have to implement the logic in WebKit yourself using the delegate methods.

Never use the "comments" feature to reply. It's a known annoyance with the forum. The comments don't trigger notifications and are hidden.

I'm not entirely sure what you're talking about. You've mentioned HTML, WebKit, WebSockets, and PDF.

I assumed from the fact that you're posting here and you mentioned WebKit that you're developing an app using WebKit and WKWebView and it isn't handling PDF downloads the way you would like.

The solution is to implement one or more of the many WebKit delegate methods to handle these HTML attributes. I don't know offhand what the exact solution is, or even if it's possible. But my guess is that it should be possible. A quick Google search suggests that that's true.

WebKit HTML Anchor download attribute ignored by PDF files
 
 
Q