User:Sardisson/Gecko is Gecko: Difference between revisions

Jump to navigation Jump to search
→‎“Runtime” Testing for Features: bz on capability sniffing done wrong
(→‎References: add a post from bz explaining how not to screw up object detection)
(→‎“Runtime” Testing for Features: bz on capability sniffing done wrong)
Line 19: Line 19:


==“Runtime” Testing for Features==
==“Runtime” Testing for Features==
If for some reason this doesn’t work for your site or application—your site can “only” function with a particular user configuration or plug-in, for instance—test the user’s browser at “runtime” to see if it supports the required function or configuration parameters.
If for some reason this doesn’t work for your site or application—your site can “only” function with a particular user configuration or plug-in, for instance—test the user’s browser at “runtime” to see if it supports the required function or configuration parameters (also called “capability sniffing”).


For example, [http://alistapart.com/articles/testdriven this ALA article] discusses methods of runtime testing of browser features to enable progressive enhancements in web pages.
For example, [http://alistapart.com/articles/testdriven this ALA article] discusses methods of runtime testing of browser features to enable progressive enhancements in web pages.


[http://www.modernizr.com/ Modernizr] and [http://diveintohtml5.org/detect.html Detecting HTML5 Features] provide sample code and libraries for feature detection for parts of CSS3 and HTML5.
[http://www.modernizr.com/ Modernizr] and [http://diveintohtml5.org/detect.html Detecting HTML5 Features] provide sample code and libraries for feature detection for parts of CSS3 and HTML5.
'''Note:''' You should never test for the presence or absence of one feature and use the result of that test to deduce a rendering engine (or, worse, browser) and then assume a set of capabilities/supported features.  (This is little more than user-agent browser sniffing in sheep’s clothing, and it is susceptible to breakage when browsers change or remove features.)  '''Instead, you should always test for the presence of specific features you want to use;''' if they are present, you can use them.[http://weblogs.mozillazine.org/bz/archives/020913.html]


==User-Agent Sniffing==
==User-Agent Sniffing==
124

edits

Navigation menu