Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Images and pdf in a div Date: Sun, 20 Jul 2014 12:42:49 +0200 Organization: PointedEars Software (PES) Lines: 76 Message-ID: <2221038.iVyETpmlb9@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1405852973 6149 eJwFwYEBgDAIA7CXcLQFzgEn/59gQtejNyAKXG7OnaVhTCf7m1UdVzTcvGhJ+eAasmvDO34WLRB2 (20 Jul 2014 10:42:53 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 20 Jul 2014 10:42:53 +0000 (UTC) User-Agent: KNode/4.12.4 X-User-ID: eJwNy8EBwCAIA8CVoASo4xg0+4/Q3v8yymsalYVUqnUDPq8heJ6VMYw73MXjtq1tCVyGHdlyQoln848hitMfW8AWPQ== Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. How about changing the code to something like: > > var AcrobatInfo = (function() { Not a constructor; by convention, the name should start lowercase. Preferably, you would put it in a private namespace, like “ap.acrobatInfo”. Creating a user-defined object that would retrieve the information about all plugins, and then would allow to retrieve information for a specific plugin, is indicated. > var isInstalled = false, > vern = null; > > function findPlugin(nme) { > var p; > for (key in navigator.plugins) { Do not use the for-in statement with host objects and array-like objects; their properties may not be enumerable, not in a defined order or have enumerable properties that you do not want to iterate over (like “refresh”); use the “for” statement instead. Exception: Array instances known to encapsulate a sparse array; in that case for-in is more efficient, and you can filter and sort the properties later, if necessary. You have not declared “key”; this code will throw a ReferenceError exception in strict mode. > […] > (function() { > var plugin; > > if (typeof window.ActiveXObject != "undefined") { Check the “ActiveXObject” property of the global object instead. > // AcroPDF.PDF is used by version 7 and later > // PDF.PdfCtrl is used by version 6 and earlier You should use multi-line comments for documentation instead, in order to be able to tell them apart from deactivating comments easily. > try { > plugin = new ActiveXObject("AcroPDF.PDF"); > isInstalled = true; > } catch(e) {} > try { > plugin = new ActiveXObject("PDF.PdfCtrl"); > isInstalled = true; > } catch(e) {} You should nest those try-catch blocks, leaving at most one empty “catch” block. “isInstalled” is superfluous because you can test against the value of “plugin” instead, which would be either not “null” or not “undefined” if successful, depending on how you initialize it. > })(); > […] > })(); I suggest you always use the same indentation for opening and closing delimiters. And “}())” instead in order to make clear what makes up the right-hand side expression. This will also become handy in editors like Vim or Eclipse JSDT with Vrapper plugin, where, which I discovered yesterday, you can type “vi)” to select everything between the outer parentheses, for refactoring. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.