Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Browser sniffing

From Wikipedia, the free encyclopedia
Website code to determine a user's browser
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Browser sniffing" – news ·newspapers ·books ·scholar ·JSTOR
(August 2022) (Learn how and when to remove this message)

Browser sniffing (also known asbrowser detection) is a set of techniques used inwebsites andweb applications in order to determine theweb browser a visitor is using, and to serve browser-appropriate content to the visitor. It is also used to detectmobile browsers and send them mobile-optimized websites. This practice is sometimes used to circumvent incompatibilities between browsers due to misinterpretation ofHTML,Cascading Style Sheets (CSS), or theDocument Object Model (DOM). While the World Wide Web Consortium maintains up-to-date central versions of some of the most important Web standards in the form of recommendations, in practice no software developer has designed a browser which adheres exactly to these standards; implementation of other standards and protocols, such asSVG andXMLHttpRequest, varies as well. As a result, different browsers display the same page differently, and so browser sniffing was developed to detect the web browser in order to help ensure consistent display of content.[1]

Sniffer methods

[edit]

Client-side sniffing

[edit]

Web pages can use programming languages such as JavaScript which are interpreted by the user agent, with results sent to theweb server. For example:

varisIEBrowser=false;if(window.ActiveXObject){isIEBrowser=true;}// Or, shorter:varisIE=(window.ActiveXObject!==undefined);

This code is run by theclient computer, and the results are used by other code to make necessary adjustments on client-side. In this example, the client computer is asked to determine whether the browser can use a feature calledActiveX. Since this feature was proprietary to Microsoft, a positive result will indicate that the client may be running Microsoft'sInternet Explorer. This is no longer a reliable indicator since Microsoft's open-source release of the ActiveX code, however, meaning that it can be used by any browser.

Standard Browser detection method

[edit]

The web server communicates with the client using acommunication protocol known asHTTP, or Hypertext Transfer Protocol, which specifies that the client send theserver information about the browser being used to view the website in aUser-Agent header.

Server-side sniffing

[edit]

Extensive browser techniques enable persistent user tracking even if users try to stay anonymous. Seedevice fingerprint for more details on browser fingerprinting.

Issues and standards

[edit]

Many websites use browser sniffing to determine whether a visitor's browser is unable to use certain features (such asJavaScript,DHTML,ActiveX, orcascading style sheets), and display an error page if a certain browser is not used. However, it is virtually impossible to account for the tremendous variety of browsers available to users. Generally, a web designer using browser sniffing to determine what kind of page to present will test for the three or four most popular browsers, and provide content tailored to each of these.[2] If a user is employing auser agent not tested for, there is no guarantee that a usable page will be served; thus, the user may be forced either to change browsers or to avoid the page. TheWorld Wide Web Consortium, which sets standards for the construction of web pages, recommends that web sites be designed in accordance with its standards, and be arranged to "fail gracefully" when presented to a browser which cannot deal with a particular standard.

Browser sniffing increases maintenance needed. Websites treating some browsers differently should provide an alternative version for other browsers. Use of user agent strings are error-prone because the developer must check for the appropriate part, such as "Gecko" instead of "Firefox". They must also ensure that future versions are supported. Furthermore, some browsers allow changing the user agent string, making the technique useless.[3]

See also

[edit]

References

[edit]
  1. ^Meiert, Jens (14 July 2021).The Web Development Glossary. Frontend Dogma.
  2. ^"Browser detection using the user agent".mdn web docs. Retrieved23 August 2022.
  3. ^Ross, David E. (2012-11-29).""Professional" Web Developers". Archived fromthe original on 2013-07-31. Retrieved2024-10-17.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Browser_sniffing&oldid=1258880628"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp