Browser switch

from Wikipedia, the free encyclopedia

Browser switches are techniques for circumventing differences in the display of web pages in different web browsers by offering different code for different browsers.

When designing websites, problems arise because not all web browsers equally support the standardized web technologies HTML , CSS and JavaScript . Older browsers in particular do not support them adequately and interpret some things differently than intended. For example, Internet Explorer prior to version 6 and also in newer versions in quirks mode uses a box model that differs from the standard . As a result, websites may be displayed correctly in one browser and incorrectly in others. The problem also affects modern browsers, since no browser has fully supported all standards to date. Nevertheless, to achieve a consistent look and functionality, in part, by the authors of Web sites browser switches are ( Engl. Browser sniffing , dt. Browser (ER) sniff ) used different to the different browsers interpret code to let.

techniques

Browser switches can be implemented on the server side (usually by reading out the browser's user agent header ) using SSI , PHP or Perl and on the client side using CSS , JavaScript (e.g. by testing for the presence of certain objects) or (for switches specifically for the Internet Explorer) Conditional Comments can be implemented.

Due to the large number of browsers, it is not possible to offer a separate version of a website for every browser and every version, which is why browser switches can also distinguish entire families of browsers (browser with Gecko engine, Internet Explorer with version> = 5, etc.).

Another method are so-called CSS hacks , in which the incorrect CSS interpretation of older versions of the browser is used in a targeted manner in order to make them behave in a special way. However, this technique is not recommended as it can cause problems with newer versions of the browser.

Problems and alternatives

Browser detection is generally not reliable, as most browsers allow a user-agent header to be transmitted and JavaScript to be deactivated. In addition, there is the problem that browser switches are only upwardly compatible to a limited extent and therefore lead to problems in the future when newer browsers come onto the market that can handle the actually desired features but are not recognized by the browser switch. Therefore, apart from a few exceptions, the main focus today is on feature detection in order to then adapt the website according to the principles of responsive web design and graceful degradation or progressive enhancement .

Cloaking

Since search engines usually use their own user agent header , browser switches can also be used to enter incorrect information about the content of a website in search engines (search engine spoofing), e.g. To B. for more advertising revenue through banner advertising the access number to increase.

Individual evidence

  1. Browser switches with SSI
  2. Example for browser recognition with PHP
  3. Browser switches with Perl
  4. a b Browser switches with CSS
  5. The Ultimate JavaScript Client Sniffer, Version 3.03: Determining Browser Vendor, Version, and Operating System With JavaScript. Retrieved on July 16, 2020 (eng).
  6. ^ Feature, Browser, and Form Factor Detection: It's Good for the Environment - HTML5 Rocks. In: www.html5rocks.com. Retrieved April 14, 2016 .