On 09/10/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
>
>
> Webunity | Gilles van den Hoven schrieb:
> > Klaus Hartl wrote:
> >> The by far safest thing to use is Conditional Compilation. And that way
> >> other browsers only get JavaScript comments...:
> >>
> > Yeah i saw that on your blog. But doesn't this affect all versions of
> > msie, even 6+ ?
>
>
> Yes, but that does jQuery.browser.msie as well. If I want to exclude IE7
>   I perform the following check:
>
> /[EMAIL PROTECTED]
> if (typeof XmlHttpRequest == 'function')
>      document.execCommand("BackgroundImageCache", false, true);
> @*/
>
> That assumes jQuery's Ajax module. Maybe you could use the variable
> @_jscript_version to make the distinction (it's 5.6 in IE6 and 5.7 in
> IE7), but I'm not sure if that ever changes with a possible update for IE6:
>
> /[EMAIL PROTECTED]
> if (parseFloat(@_jscript_version) < 5.7)
>      document.execCommand("BackgroundImageCache", false, true);
> @*/
>
>
> -- Klaus
>

I think, if possible, the browser detection should check browsers
through something other than the user agent.

// Figure out what browser is being used
jQuery.browser = {
        safari: /webkit/.test(b),
        opera: !!window.opera,
        msie: /[EMAIL PROTECTED]
        /[EMAIL PROTECTED] (@_jscript)
        true
        @else @*/
        false
        /[EMAIL PROTECTED] @*/
        mozilla: !!window.Components
};

This assumes no one creates an object called 'opera' or 'Comnponents'
on the window object. I'm not sure what is unique in Safari as I can't
find any pages on Apple detailing the DOM in Safari.

Not friendly with Dean Edwards' packer tool though, which won't be
able to compress any code that uses conditional comments without
breaking it.

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to