- From: Jim Ley <jim@jibbering.com>
- Date: Fri, 9 Nov 2001 14:50:47 -0000
- To: <www-dom@w3.org>
"Neil Laurance": > --- Jim Ley <jim@jibbering.com> wrote: > Jim. Could you elucidate what you mean by 'object detection'. I am not familiar > with this term. Object detection, if you want to choose between using two different objects, you literally see which object is available and use that if (window.document) doc=window.document else if (window.neil) doc=window.neil etc. The only risk of this technique is if window.document exists but isn't what you think it is, this can be checked with a "typeof object" - but in general that's rarely needed as it's very unlikely and currently unknown that getElementById is going to be anything but the standard function. so is generally not checked for. This can of course be followed through to any object if (document.getElementById) el=document.getElementById('moomin') if (moomin && moomin.style) moomin.style.backgroundColor='red' etc. this way any browser which supports the relevant objects it will work on, and any others it won't error. You need to check every object though. http://www.mozilla.org/docs/web-developer/upgrade_2.html has more on this (watch out for other mozilla pages...) Jim.
Received on Friday, 9 November 2001 09:51:50 UTC