17 December 2008

Set 'float' property of DOM element

Usual syntax of setting any style property of DOM element is

element.style.styleName = value;

For example,

var oDiv = document.createElement('div');
oDiv.style.width = "100px";
oDiv.style.height= "100px";

But as 'float' is a reserved keyword, we CAN'T follow the same convention.

oDiv.style.float = "right"; // wrong

Unfortunately, all browsers don't handle this exception in same way (disgusting!!). So, we have to set two properties like below

oDiv.style.cssFloat = "right"; // for standards compliant browsers
oDiv.style.styleFloat = "right"; // for IE and may be for some other browsers

for more about style you can follow this link.

0 Comments:

 

© 2007 t!ps n tr!cks: Set 'float' property of DOM element



Template unik dari rohman


---[[ Skip to top ]]---