Content deleted Content added
m Removing irrelevant category |
Citation bot (talk | contribs) Removed parameters. | Use this bot. Report bugs. | #UCB_CommandLine |
||
(13 intermediate revisions by 11 users not shown) | |||
Line 1:
{{More citations needed|date=March 2014}}
'''Feature detection''' (also '''feature testing''') is a technique used in [[web development]] for handling differences between [[runtime environments]] (typically [[web browsers]] or [[user agents]]), by programmatically testing for clues that the environment may or may not offer certain functionality. This information is then used to make the application adapt in some way to suit the environment: to make use of certain [[API|APIs]], or tailor for a better user experience.{{Citation needed|date=March 2014}}▼
▲'''Feature detection''' (also '''feature testing''') is a technique used in [[web development]] for handling differences between [[runtime environments]] (typically [[web browsers]] or [[user agents]]), by programmatically testing for clues that the environment may or may not offer certain functionality. This information is then used to make the application adapt in some way to suit the environment: to make use of certain [[API
Its proponents claim it is more reliable and future-proof than other techniques like [[User_agent#User_agent_sniffing|user agent sniffing]] and browser-specific CSS hacks.{{Citation needed|date=March 2014}}▼
▲Its proponents claim it is more reliable and future-proof than other techniques like [[
==Techniques==
A feature test can take many forms. It is essentially ''any'' snippet of code which gives some level of confidence that a required feature is indeed supported. However, in
As [[JavaScript]] is the most
The simplest technique is to check for the existence of a relevant object or property. For example, the Geolocation API (used for accessing the
<nowiki>
Line 18 ⟶ 20:
}</nowiki>
For a higher level of confidence, some feature tests will attempt to invoke the feature then look for clues that it behaved properly. For example, a test for support for [[
==Undetectables==
Some browser features are considered ''undetectable'', because no clues are known to give sufficient confidence that a feature is supported. These are often because limited information available to the JavaScript environment in the browser; generally features must be exposed via the DOM in some way in order to be
When undetectables are encountered, it is common to turn to [[
The [[Modernizr]] project maintains a record of known undetectables on their [
==See also==
* [[Browser sniffing]]
* [[Progressive enhancement]]
* [[Modernizr]]
==References==
{{Reflist}}
[[Category:Web accessibility]]
|