javascript - getting the Width of an element without padding in Internet Explorer -


i want fit images on site size of containing element, have this:

if (userhasmicrositephoto) {     var width = $('micrositephotodiv').getcomputedsize().width;     $('micrositephoto').src = "flash/userimage.ashx?type=micrositephoto&id=" + userid + "&width=" + width; } 

my handler file userimage.ashx returns image given id, scaled width given parameter.

this works fine in firefox, chrome & co, doesn't work in internet explorer - image returned large. think because .getcomputedsize().width reports width includes size of padding (but on border or margin) in internet explorer, returns usable area in other browsers. result, width given internet explorer large.

i can't find other fields accessable for.getcomputedsize() allows me find 'actual' width in internet explorer. tried using .getcomputedstyle() padding subtract total width, returns string, , styling micrositephotodiv element padding: 0.75em, doesn't work.

what need right width in internet explorer?

you can make padding 0, checking computed styles sizes , positions buggy , hard reconcile acreoss browsers.

use offsetwidth or clientwidth instead, on browsers.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -