views:

2460

answers:

1

After loading an internal div (#book_table) via ajax, I want to resize the width of the body to accommodate the larger content.

var new_width = parseInt($('#book_table').css('width'))+407;
$('body').width(new_width);

Works in FF and Safari, but fails in IE with "Invalid argument". In the unpacked jQuery 1.3.1, it's line 1049:

elem[ name ] = value;

Passing a literal value, however, works in IE:

$('body').width(1200);
+8  A: 

You should try:

var new_width = $('#book_table').width() + 407;
$('body').width(new_width);

Using css('width') is returning a string with the 'px' extension rather than simply a number. Firefox can properly parse "100px" to be 100 with parseInt, but it looks like IE does not.

Using width() will just return an integer, which also removes the need to call parseInt.

TM