Home > Web Front-end > JS Tutorial > Method to detect browser type and version under jquery1.9_jquery

Method to detect browser type and version under jquery1.9_jquery

WBOY
Release: 2016-05-16 17:06:51
Original
1376 people have browsed it

$.browser has been eliminated in Jquery1.9 version:

Determine browser type:

Copy code Code As follows:

$.browser.mozilla = /firefox/.test(navigator.userAgent.toLowerCase());
$.browser.webkit = /webkit/.test(navigator.userAgent .toLowerCase());
$.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
$.browser.msie = /msie/.test(navigator.userAgent.toLowerCase ());

The expression after the equal sign returns true/false, which can be directly used to replace the original $.browser.msie, etc.

Check whether it is IE6:
Copy the code The code is as follows:

/ / Old
if ($.browser.msie && 7 > $.browser.version) {}
// New
if ('undefined' == typeof(document.body.style.maxHeight) ) {}

Check if it is IE 6-8:
Copy code The code is as follows:

if (!$.support.leadingWhitespace) {}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template