Modify ↓
Ticket #1134 (closed enhancement: duplicate)
Better browser type and version detection
| Reported by: | hobbit | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.1.3 |
| Component: | core | Version: | 1.1.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Better browser detection script (not finished).
new function(){
var
//When the script run, the html element already exists.
html=document.getElementsByTagName("html")[0],
b=navigator.userAgent.toLowerCase(),
version=
b.match(/opera.(d+.d+)/) ||
b.match(/; rv:(d+.d+.d+)/) ||
b.match(/applewebkit.(d+(.d+)?)/) ||
b.match(/msie (d.d+)/);
$.browser.msie = html.style.filter !== undefined;
//MozBoxAlign attrib supported since Gecko 1.0.x.
$.browser.mozilla = html.style.MozBoxAlign !== undefined;
//opPhonemes attrib supported since Opera 8.0.
$.browser.opera = html.style.opPhonemes !== undefined;
//$.browser.safari = ???;
$.browser.version = (version.length && version[1]) || null;
$.boxModel = !$.browser.msie || document.compatMode == "CSS1Compat";
//I don't know this expression works on Macintosh.
//$.browser.msie = /*@cc_on true || @*/ false;
}
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

This should be mentioned as a follow-up to ticket #1101. It's important to note that doing browser detection (instead of feature detection) is exactly what's needed here. Detecting an obscure browser feature can have future, unintended, consequences.