views:

8

answers:

1

Browsers can display certain media inline, and will provided they are sent with content-disposition: inline. What's the best way to detect whether the browser is capable of doing so with a particular type of media?

I am running into the question lately with PDFs and Mac/FF, which seems to refuse to display PDFs inline (actually, in iFrame), instead prompting a download. I don't mind the forced download; I'd just like to be able to anticipate it so that I can give the end user a nice "download" link rather than an iFrame that fails at displaying inline content. My current solution is just browser detection (sample code below), but surely there must be a better mode.

var isMacFF = window.navigator.userAgent.search(/Mozilla.*Mac/i) != -1
+1  A: 

This doesn't directly answer the question, but something you need to be aware when analyzing any answer you get - you can NOT reliably 100% determine that due to assorted browser plug-ins.

Specifically, in case of FireFox, look at PDF Downloader as an example - it basically allows the user 100% full control over how PDF gets displayed.

DVK