Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#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:
Blocked by: Blocking:


Better browser detection script (not finished).

new function(){
  //When the script run, the html element already exists.
    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 (2)

comment:1 Changed 16 years ago by john

Resolution: duplicate
Status: newclosed

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.

comment:2 in reply to:  1 Changed 16 years ago by hobbit

Replying to john:

And if the user agent string is modified, the jQuery not works correctly. Example the conditional compilation works only in Internet Explorer since version 5.0. This detection is trusty: /*@cc_on true
@*/ false;
Note: See TracTickets for help on using tickets.