>From what I understand, it's discouraged to use functions like isIe,
isGecko, etc. to fork your condition on how you calculate or
manipulate objects.

There are a few good reasons for this, especially that the box model
in future versions (or different current versions) of the same browser
might change.  You might argue that a secondary check on different
versions might help, but there are some instances where a browser can
"spoof" its identification (I know Opera at least has this ability) so
you can't rely on these ID strings, anyway.  Furthermore, even if
there was a foolproof way of determining box model type, it would be a
maintenance headache to accommodate all the browsers, and a continual
one since new browser versions come out all the time.  Browser IDs are
usually a last resort.

If you *really* need pixel precision in your design, and you can't fix
it in the CSS/HTML structure when the page first comes up, you should
probably set padding and border-width to 0 and use offset values for
internal elements (or create an inner DIV that has a fixed upper-left
corner and width/height).  This is not only standards-compliant but
would work around the differences in browser box-models.

 - Kevin


On 9/3/06, ErrieR <[EMAIL PROTECTED]> wrote:
>
> Hi everybody,
>
> In some browsers (Firefox, Opera, etc.) border-width and padding are
> added to the width and height of the div.
> This is not what I want when I set width and height of a div, so
> actually width = width - 2*border-width - 2*padding, and height =
> height - 2*border-width - 2*padding.
> If border-style is 'none', I ignore border-width in calculations.
>
> Wouldn't it be nice if MochiKit.setElementDimensions figured out the
> boxing model differences for us by means of the MochiKit.Base.isIe,
> isGecko, isKHTML, isSafari and isOpera functions (when the element is a
> div)?
>
> As far as I can see, the MochiKit.setElementDimensions function only
> updates the style attributes.
>
>     /** @id MochiKit.Style.setElementDimensions */
>     setElementDimensions: function (elem, newSize/* optional */, units)
> {
>         elem = MochiKit.DOM.getElement(elem);
>         if (typeof(units) == 'undefined') {
>             units = 'px';
>         }
>         MochiKit.DOM.updateNodeAttributes(elem, {'style': {
>             'width': newSize.w + units,
>             'height': newSize.h + units
>         }});
>     },
>
> Am I missing something here? Please let me know what you think of it.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" 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/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to