Hi Dan,
I think it's a good idea, I already use a similar thing, but as others
have said it may be better as a plugin.

It would be good if everyone could agree on standard class names, and
where to put the plugin -
I don't think it would be necessary to put it in $.fn

I'm not sure if tacking 'jquery-' to each class is necessary, makes
the CSS a bit long winded,
but I guess it wouldn't hurt to allow passing of a prefix to the
plugin.

Anyway, how's this:

(function($) {
$.addBrowserClass = function(prefix) {
        var b = $('body'), p = prefix || '';
        jQuery.each($.browser, function(n,v) { if (v === true) { b.addClass(p
+n); } });
        if ($.browser.msie) { b.addClass(p+'ie'+$.browser.version.split('.')
[0]); }
        b.addClass($.boxModel ? p+'w3c' : p+'quirks');
};
})(jQuery);

Which adds a class name for the browser, version numbers for IE, and
the box model mode.

On Dec 8, 2:30 pm, "Dan Switzer" <[EMAIL PROTECTED]> wrote:
> A thought has a occurred to me a couple of times over the past week or
> so, it would be awful convenient for jQuery to automatically add
> classes to the body tag to indicate the browser and version. While I
> know this can be done manually, it seems almost every visual plug-in
> is using some form of CSS hack to fix various browser issues.
>
> I think it would be beneficial to the developers if jQuery just
> automatically tagged the body with classes, so that CSS hacks can be
> prevented altogether.
>
> What I was thinking is that jQuery would add two classes to the body
> element, one indicating the browser and one indicating the browser
> *and* version.
>
> For example, for browser something like:
> jquery-msie
> jquery-mozilla
> jquery-safari
>
> And then for version, something like:
> jquery-msie-6
> jquery-msie-7
> jquery-msie-8
>
> The reason I'm suggesting 2 classes is often you just need specific
> CSS for an entire browser line, but obviously sometimes you need to
> target a specific version.
>
> I think this would help with the UI projects as well. This should be
> easy to implement and not really add much to the overall source code
> base, but would be a huge help in developing CSS for sites. By having
> jQuery add the classes it uniforms everything, so developers aren't
> constantly having to re-invent the wheel and using their own
> techniques.
>
> Any comments?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to