Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Images and pdf in a div Date: Sat, 19 Jul 2014 13:34:01 +0200 Organization: solani.org Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1405769630 4280 eJwFwYEBwCAIA7CXVi0g51QY/59gYtvhFXRz2tgUajX0qbpKzRN3D8mbrYWlo/kz0hqeDuQDOqERiA== (19 Jul 2014 11:33:50 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 19 Jul 2014 11:33:50 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 X-User-ID: eJwNwgERwDAIA0BLg0HADg2pfwnb/ecLAyuQiLy/NYhmnBPpONa9WU5BG3g67nIGNfKlyj8j4hG7 In-Reply-To: Cancel-Lock: sha1:gGvjifmFgcIhf6qKKHURzhgA8Hc= X-NNTP-Posting-Host: eJwNycERACEIA8CW5DCBlMOg9F+Ct9+F09ixCW4MRorzVchNCU1aeCkKl2d6mWvVJSN7/kPPAwhUEM4= Xref: csiph.com comp.lang.javascript:25475 danca wrote: > When the thumbnails points to a PDF, however, I have to change the div, > particularly I: > -create a new embed node > -use replaceChild to switch the node image with the newly created node > embed. > I could anyway go another route: > create the two nodes and simply give display:none to alternatively the > image and the embed node, without the use of replaceChild. > > Has someone an idea about cross-browsers issues with the first approach? > It works with all the (main, modern) browsers on a pc. Android browser > is OK too, but I'm unsure about iPads and iPhones (and I have no one to > test with). 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. -- Christoph M. Becker