Setting DOM element height and width thru style in IE and Firefox

I was using a pretty standard line of JavaScript code to set dimentions of an HTML element, something like:

oDiv.style.height = iWindowHeight/2 - 50;

It was working fine in IE, but had no effect whatsoever in Firefox.
Turned out all that was needed – to add ‘px’ to that line:

oDiv.style.height = iWindowHeight/2 - 50 + 'px';

and it works fine in both browsers.

Leave a Reply