Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25481
| Date | 2014-07-20 15:23 +1000 |
|---|---|
| From | Andrew Poulos <ap_prog@hotmail.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Images and pdf in a div |
| References | <lqc77u$ljp$1@dont-email.me> <lqdl2u$45o$1@solani.org> <lqds4k$iad$1@dont-email.me> <XnsA36FA164733A9eejj99@194.109.133.133> <lqe6fa$sid$1@dont-email.me> |
| Message-ID | <m_CdnTCZ5NKWzlbOnZ2dnUVZ_tGdnZ2d@westnet.com.au> (permalink) |
On 20/07/2014 2:30 AM, danca wrote:
> Il 19/07/2014 15:51, Evertjan. ha scritto:
>> <http://thecodeabode.blogspot.nl/2011/01/detect-adobe-reader-plugin.html>
>>
>> I did not test this, btw.
>>
> I feared an answer like this. Thanks, no.
>
> (excerpt)
>
> var getBrowserName = function() {
> return this.name = this.name || function() {
> var userAgent = navigator ? navigator.userAgent.toLowerCase() :
> "other";
>
> if(userAgent.indexOf("chrome") > -1) return "chrome";
> else if(userAgent.indexOf("safari") > -1) return "safari";
> else if(userAgent.indexOf("msie") > -1) return "ie";
> else if(userAgent.indexOf("firefox") > -1) return "firefox";
> return userAgent;
>
> ugh.
How about changing the code to something like:
var AcrobatInfo = (function() {
var isInstalled = false,
vern = null;
function findPlugin(nme) {
var p;
for (key in navigator.plugins) {
p = navigator.plugins[key];
if (p.name == nme) return p;
}
return null;
}
(function() {
var plugin;
if (typeof window.ActiveXObject != "undefined") {
// AcroPDF.PDF is used by version 7 and later
// PDF.PdfCtrl is used by version 6 and earlier
try {
plugin = new ActiveXObject("AcroPDF.PDF");
isInstalled = true;
} catch(e) {}
try {
plugin = new ActiveXObject("PDF.PdfCtrl");
isInstalled = true;
} catch(e) {}
if (plugin) {
vern = plugin.GetVersions().split(',')[0].split('=')[1];
}
} else {
plugin = findPlugin('Adobe Acrobat')
|| findPlugin('Chrome PDF Viewer')
|| findPlugin('WebKit built-in PDF');
if (plugin) isInstalled = true;
if (plugin && plugin.version) vern = plugin.version;
}
plugin = null;
})();
return {
installed: isInstalled,
version: vern
};
})();
Usage
var a = "Acrobat is "
+ (AcrobatInfo.installed?"":"not")
+ " installed. "
+ AcrobatInfo.version;
One shortcoming is that while FF will return the full version string (eg
10.1.7.27) IE 9 only returns part of the version string (eg 10.1.)
Andrew Poulos
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 00:31 +0200
Re: Images and pdf in a div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-07-19 13:34 +0200
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 15:34 +0200
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-19 15:51 +0200
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 18:30 +0200
Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-20 15:23 +1000
Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-20 12:42 +0200
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-20 20:07 +0200
Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-21 14:10 +1000
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-21 14:19 +0200
Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-21 08:14 +1000
Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-21 02:00 +0200
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-21 07:15 +0200
Re: Images and pdf in a div Osmo Saarikumpu <osmo@weppipakki.com> - 2014-07-24 18:26 +0300
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-24 17:48 +0200
Re: Images and pdf in a div Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-24 22:32 +0100
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-24 23:58 +0200
Re: Images and pdf in a div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-07-24 18:40 +0200
Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-25 12:31 +0200
Re: Images and pdf in a div John Harris <niam@jghnorth.org.uk.invalid> - 2014-07-25 15:52 +0100
csiph-web