Flag This Hub

How To Fix the IE6 Box Model with jQuery

By


After stumbling over the jQuery bug that displays the wrong version for IE7, I pursued the idea of using jQuery to "fix" IE6 like Dean Edward's IE7-js script.  As of right now, I only implemented a box model fix that can be selectively executed within jQuery chaining.

$("#footer").fixBox();

I don't know if this method is solid or if there are some bugs but it seems like a neat little way to get around some of the IE6 pains.

jQuery.fn.fixBox = function() {
   return this.each(function() {
     var $$ = $(this);
     var hd = $$.outerHeight() - $$.height();
     var wd = $$.outerWidth() - $$.width();

     if (!$$.boxModel) {
       if ($$.css("height") != "auto" && hd > 0) $$.height($$.outerHeight() + hd);
       if ($$.css("width") != "auto" && wd > 0) $$.width($$.outerWidth() + wd);
     }
   });
 };

Comments

No comments yet.

Submit a Comment
Members and Guests

Sign in or sign up and post using a hubpages account.



    Like this Hub?
    Please wait working