Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder2.enfer-du-nord.net!news.weisnix.org!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <3001757.SPkdTlGXAF@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Thu, 17 Nov 2011 21:06:51 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit Subject: Re: David Mark's Javascript Tip Du Jour - Volume #1 - Tip #1234 - How to Measure Element Dimensions Newsgroups: comp.lang.javascript References: <1529063.40VBb9nUPl@PointedEars.de> <1934317.nKmheAe9J7@PointedEars.de> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 41 NNTP-Posting-Date: 17 Nov 2011 21:06:52 CET NNTP-Posting-Host: b284f402.newsspool3.arcor-online.net X-Trace: DXC=7mAFcfC2\e?RLigj];iP=8McF=Q^Z^V384Fo<]lROoR18kF Thomas 'PointedEars' Lahn writes: >> This is actually one case where property inference (window.opera) is >> useful and acceptable; […] > > var opera = 'Der Ring des Nibelungen'; Don't be ridiculous. Oh wait, it's you. > On the other hand, Opera has a proper way of dealing with > (version-)detection (unless the opera object is shadowed, and I’d rather > have a false negative than a false positive; but surely YMWD), e.g.: > > var OPERA = (function (global) { > var dom_window = global.window, AISB. > opera, > version, > subversion, > build; > if ('object' == typeof dom_window.opera) { You have overlooked the case of dom_window.opera === null. Also, it is a host object, so all bets (other than it would have to be a true-value to be useful) are off. > opera = dom_window.opera; > // the version method was introduced in Opera 8 > if (('function' == typeof opera.version) && > ('function' == typeof opera.buildNumber) You have overlooked the case where a host object's method would not yield `function', which might be the case with Opera's DOM implementation. PointedEars -- When all you know is jQuery, every problem looks $(olvable).