Re: Best way to deal with Javascript (in)compatibility using PHP?



On 29/06/2005 13:39, Philip Ronan wrote:

[snip]

http://www.google.co.uk/search?q=javascript+object+detection

The term, object detection, probably isn't the best one to use. It has connotations with 'Browser detection via object inference', as you might notice by looking at some of the search results. A better phrase to consider is feature detection, and it is this principle that the OP should be trying to embrace.


The actual browser that is in use should normally be of absolutely /no/ concern. The only interest should be what the capabilities are of that browser (hence /feature/ detection).

Feature detection typically involves a one-to-one analysis of the environment. Simply assuming that because the host supports - for instance, document.getElementById - that it must automatically support the entire W3C DOM Core module is clearly flawed (though that's what many seem to do). Instead, one determines what is necessary to perform a particular task, and then sets about finding if those methods and objects are indeed present in the host environment. Doing this in an efficient manner typically requires a thorough understanding of ECMAScript.

The FAQ notes for comp.lang.javascript gives a more in-depth treatment of why the various detection methods are flawed, and why feature detection is vastly superior (including some simpler examples). If you have particular issues, post there.

See <URL:http://www.jibbering.com/faq/faq_notes/not_browser_detect.html>

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
.



Relevant Pages

  • Re: Distinguishing Mac OS X Versions
    ... When you break new ground with browser detection, ... What I imagine the OP wants to do is offer a different program download ... system choices. ... The lesson is that feature detection is not a solution for everything, ...
    (comp.lang.javascript)
  • Re: IE6/7+Vista check
    ... worth it. ... As flawed as feature detection and more dangerous. ... Did you mean browser detection or do you really believe that feature ...
    (comp.lang.javascript)
  • Re: IE6/7+Vista check
    ... worth it. ... Did you mean browser detection or do you really believe that feature detection is flawed? ...
    (comp.lang.javascript)
  • Re: jQuery 1.3 Released
    ... Maybe embarrassing but not surprising in my experience of both John Resig's site and the JQuery site. ... We all knew that browser sniffing actually necessities continuous updates (and feature detection can totally avoid the need, in the right context), it is just a bit ironic that removing the browser sniffing also necessitates an update. ... There seems to be a huge confusion between feature detection and object inference browser detection ...
    (comp.lang.javascript)