I don't like this since it depends on checking in a particular order. B.gecko is true for safari/chrome, B.applewebkit is true for chrome, B.mozilla is true for most everything (including msie).
That seems like it definitely violates the principle of least surprise to me: http://en.wikipedia.org/wiki/Principle_of_least_astonishment --Erik On Thu, Sep 18, 2008 at 4:39 AM, Andrea Giammarchi < [EMAIL PROTECTED]> wrote: > Hi guys, > I wonder if these 2 lines of code are enough to make everybody happy :D > > B = function(RegExp, browser){ > while(arguments = RegExp.exec(navigator.userAgent)) > browser[arguments[1].toLowerCase()] = arguments[3]; > return browser; > }(/\b(\w+)\b(\/| )([0-9\.]+)/g, {}); > > //* test */ for(var k in B) alert(k + " = " + B[k]); > > In this case we can check everything without maintain code. > As example: > > if(B.firefox)... > else if(B.msie)... > else if(B.chrome)... > else if(B.applewebkit)... > else if(B.safari)... > else if(B.gecko)... > else if(B.msie)... > > Plus extra information, like: > > if(B.nt)... > > So, one regexp, every possible case plus browser version as string. > > alert(B.firefox > "3.0.0" && B.firefox < "3.0.2"); > > Regards > > > > On Wed, Sep 17, 2008 at 10:05 PM, Ariel Flesler <[EMAIL PROTECTED]>wrote: > >> >> We can always have a plugin (and there are already) that adds any >> amount of flags to $.browser. >> As long as we don't need to bifurcate the core's code, there's no need >> for this addition IMO. >> >> -- >> Ariel Flesler >> http://flesler.blogspot.com/ >> >> On Sep 17, 9:25 am, "John Resig" <[EMAIL PROTECTED]> wrote: >> > The word 'safari' is just legacy - just pretend that it's 'webkit'. >> > >> > --John >> > >> > On Wed, Sep 17, 2008 at 4:38 AM, Sam Collett <[EMAIL PROTECTED]> >> wrote: >> > > Firefox isn't even in jQuery.browser, so unlikely Chrome will be. If >> Chrome >> > > is added, Firefox should be too. Although Safari is in it instead of >> WebKit >> > > (not sure why that is, especially since the version does not match the >> > > browser). >> > >> > > --Sam >> > >> > > 2008/9/16 jonhobbs <[EMAIL PROTECTED]> >> > >> > >> I wish this is true but unfortunately it doesn't seem to be. >> > >> > >> <select> lists look completely different for example. >> > >> > >> Jon >> > >> > >> On Sep 4, 1:29 pm, "John Resig" <[EMAIL PROTECTED]> wrote: >> > >> > Don't see a reason to add it. Really should be treated any >> differently >> > >> > than >> > >> > any other WebKit engine is (unfortunately named 'safari' in >> .browsers). >> > >> > >> > --John >> > >> > >> > On Thu, Sep 4, 2008 at 6:59 AM, Erik Beeson <[EMAIL PROTECTED] >> > >> > >> > wrote: >> > >> > > Chrome on Vista is reporting: >> > >> > > Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) >> AppleWebKit/525.13 >> > >> > > (KHTML, >> > >> > > like Gecko) Chrome/0.2.149.27 Safari/525.13 >> > >> > >> > > Will this be added to jQuery.browser? >> > >> > >> > > --Erik >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---
