[jQuery] jQuery Browser Detection

[jQuery] jQuery Browser Detection

Currently, jQuery does a browser detect by checking the user agent.
However, I think object detection would probably be a better way.
This code does that by detecting unique obects on the window object.
However, I am not sure what is unique to Safari.
// Figure out what browser is being used
jQuery.browser = {
    safari: /webkit/.test(b),
    opera: !!window.opera && !!window.opera.defineMagicFunction,
    msie: !!window.clipboardData,
    mozilla: !!window.XPCNativeWrapper
};
The chance of someone defining 'window.opera.defineMagicFunction',
window.clipboardData' and 'window.XPCNativeWrapper' is virtually non
existent (far far less likely than someone changing the user agent
string).
defineMagicFunction
(http://www.opera.com/support/tutorials/userjs/specs/) is used by user
scripts on Opera, clipboardData
(http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/clipboarddata.asp)
is for working with the clipboard and XPCNativeWrapper
(http://kb.mozillazine.org/XPCNativeWrapper) is used by privileged
code (i.e. extensions) to access unprivileged code (i.e. content on a
webpage) in a secure way.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/