Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HOWTO: Detect from IE web page if Acrobat/ Reader installed

2 views
Skip to first unread message

SaGS

unread,
Oct 15, 2001, 4:40:41 AM10/15/01
to
The problem
Sometimes, web pages need to determine if Acrobat Reader (or the full
Acrobat) is installed on the client computer or not. If I know
correctly, with Netscape that's simple: check the navigator.mimeTypes
array. With Internet Explorer, this array is not available.

The solution I suggest
At the end of this posting there is a HTML file that displays a
different text, depending on Acrobat/Reader being installed or not
(and some other text if scripting is disabled, in which case the test
cannot be performed).
Requirements:
a) scripting - however, it degrades gracefully if scripting turned
off;
b) style-sheets - to hide elements while loading, but it can be
rewritten (redirects and no initial non-blank content) to be
independent on CSS avalability;
c) Internet Explorer 4+ - but the idea should work with any
recent-enough browser.

First, the basic idea and some comments:
a) A PDF file can be embedded in a HTML using the <OBJECT> (maybe
the obsolete <EMBED> too) element.
b) The <OBJECT> element may have contents, in addition to any
<PARAM>s it needs. This content is ignored if the object can be
created, and rendered in the oposite case. (The intent is to
provide an alternate to display if the object's type is unknown
to the browser.) What we test in fact is the presence of this
alternate content.
c) Unfortunately, it seems the <OBJECT> and its content are
processed asyncronously, so the test is reliable only after the
onload event fires. In particular, the result is not available
to a script run while parsing the HTML (to do a conditional
document.write(), for example).
d) If no PDF file is specified, Acrobat/Reader does not display
anything, but no error appears. This is used as an optimization
(the server is not contacted to get a PDF, and nothing extra
needs to be downloaded).
e) The <NOSCRIPT> and </NOSCRIPT> tags are used to hide the
"don't know" version if scripting is enabled - avoids text
flickering on screen.
f) Instead of showing/ hiding elements, you can choose to redirect
to different pages, and put the actual contents in those. This
may be faster, since the initial file will be very short, but
requires extra files.
g) A <META http-equiv="refresh" ...> inside the <OBJECT> would allow
to solve the problem without scripting, but it doesn't work there.

--- Cut here and save as "IsAcrobatInstalled.html" -------------------
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META http-equiv="Content-Style-Type" content="text/css">
<META http-equiv="Content-Script-Type" content="text/javascript">
<TITLE>Checking if Acrobat Reader installed (IE4+)...</TITLE>
<SCRIPT for="window" event="onload"><!--
document.all [
document.all.PDFNotKnown ? "IfNoAcrobat" : "IfAcrobat"
] .style.display = "block";
//--></SCRIPT>
</HEAD>
<BODY>
<NOSCRIPT>
Cannot determine if you have Acrobat Reader (or the full Acrobat)
installed <FONT size="-1">(because JavaScript is unavailable or
turned off)</FONT>.
</NOSCRIPT
><DIV id="IfAcrobat" style="display:none">
You <B>already have</B> Acrobat Reader (or Acrobat) installed.
</DIV
><DIV id="IfNoAcrobat" style="display:none">
You <B>need</B> to install Acrobat Reader (or the full Acrobat).
</DIV
><OBJECT type="application/pdf" width=0 height=0 style="display:none">
<DIV id="PDFNotKnown" style="display:none">&nbsp;</DIV>
</OBJECT
></BODY
></HTML>
----------------------------------------------------------------------

0 new messages