Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25480

Re: Images and pdf in a div

From danca <cyberdanny@tiscalinet.it>
Newsgroups comp.lang.javascript
Subject Re: Images and pdf in a div
Date 2014-07-19 18:30 +0200
Organization A noiseless patient Spider
Message-ID <lqe6fa$sid$1@dont-email.me> (permalink)
References <lqc77u$ljp$1@dont-email.me> <lqdl2u$45o$1@solani.org> <lqds4k$iad$1@dont-email.me> <XnsA36FA164733A9eejj99@194.109.133.133>

Show all headers | View raw


Il 19/07/2014 15:51, Evertjan. ha scritto:
> danca <cyberdanny@tiscalinet.it> wrote on 19 jul 2014 in
> comp.lang.javascript:
>
>> Il 19/07/2014 13:34, Christoph M. Becker ha scritto:
...
>>>
>>> I don't see any problems regarding the replacement of the node (i.e.
>>> your first approach).
>>>
>>> However, the embed element surely requires a PDF reader/renderer to be
>>> available in the browser (e.g. the Adobe Acrobat plugin).  If that is
>>> not available, the browser likely will render an empty space or maybe an
>>> error message.  Perhaps it is reasonable to display a preview image
>>> instead of the PDF document.
>>>
>> It is unclear to me how to detect preliminarly the availability of the
>> plugin, or which syntax to use to have a fallback to a preview image.
>> I am a bit puzzled with this idea, it sounds good but I would greatly
>> appreciate a hint.
>> My basic code is something like this:
>> ...
>> var oldNode=document.getElementById("doc")
>> var newNode=document.createElement("embed")
>> newNode.type="application/pdf"
>> newNode.src="http://"+location.host+"/images/test.pdf"
>> oldNode.parentNode.replaceChild(newNode,oldNode)
>> newNode.id="doc" // ready for another substitution - same id as previous
>> ...
>> then I resize the div container etc.
>> So... what kind of feature must I look for?
>
> Google is your friend, I hope:
>
> <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.
btw weren't we all negative about browser sniffing? I'm doing my best to 
follow best practices and this NG is a big resource in this matter.
(Still learning, as all my life is about).

Uhm no, I'll not support people not able to correctly display a pdf in 
their browser. They can download the file and see it offline.

Apart the fact that this all is about a CMS-like system, the script part 
being a fragment of the total, the publisher decides what to publish and 
his audience, so if one comes and has no pdf support it is not my 
problem at the end of the tale, if not in a very indirect way.

Anyway I hope my question is of interest for someone else.
When it comes to "particular" questions this is the only place to go. 
Thanks!
Dan

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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