Re: Best way to deal with Javascript (in)compatibility using PHP?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

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

From: Michael Winter <m.winter@blueyonder.co.invalid>
Date: Wed Jun 29 2005 - 17:39:40 CEST

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.
Received on Mon Oct 17 20:59:19 2005