14. jquery Parsing Browser sniffing

Source: Internet
Author: User

Chrome and Safrai use WebKit as the kernel engine, so if
JQuery.browser.webkit is true to indicate that the browser is Chrome or safari;
If JQuery.browser.mozilla is true, it means that the browser is Mozillafirefox (Firefox);
Jquery.browser by parsing the navigator.useragent to get the browser type and version number, this technique is also known as browser sniffing technology.
Navigator is a property of the Global Object window, pointing to a navigator object that contains information about the browser being used;
Navigator.useragent contains the value of the user agent (user-agent) that the browser uses for HTTP, the request.
Avoid writing code that is based on a particular type or version number, because it can cause code to be closely linked to a particular browser type or version, and the browser's navigatoe.useragent is modifiable;
the best way to solve the browser is to test the code based on browser functionality.
The resolution for Navigator.useragent is implemented by Method Jquery.uamatch (UA).

This code is used to parse the user agent Navigator.useragent 4 regular expressions;
Each regular consists of two groups: Browser type feature characters and browser version feature characters.

Assigns a value to useragent.

858~868: Defines the method Jquery.uamatch (UA) that resolves the current browser's type and version number. In this method, try to match the user agent navigator.useragent with 4 regular expressions, and return the value of the result in the following format.
{
Browser: "",
Version: ""
}

899~903: Call Jquery.uamatch (UA) To resolve user agent nabigator.userabent. Do not reseal the parsing results to Jquery.browser.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.