• Home
  • About
  • Resume

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

By , 07/09/2009 12:44 PM

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.

Panorama Theme by Themocracy