[Javascript] DOM: adding CSS to created DIV

David Dorward david at dorward.me.uk
Mon Jan 22 02:35:08 CST 2007


On Mon, Jan 22, 2007 at 09:24:02AM +0100, Michael Borchers wrote:
> The first version works fine for FF, but not for IE.

> entryLayer.setAttribute('id','calendarEntryFormLayer');
>    // FF, not IE:
>    entryLayer.setAttribute('style','position:absolute;left:200px;top:300px;width:100px;height:100px;background-color:#ffffff;color:#ffffff;;border:1px 
> solid #0b234c;padding-left:10px;z-index:3000;display:block;');
 
> any reason? 

Internet Explorer's implementation of setAttribute is very broken.

I suspect it looks something like this:

function (attribute, value) {
  element[attribute] = value;
}

... so if the HTML attribute syntax is different from the accessor
property (as style is) or if the property and attribute names are
different (class/className) then it breaks.

-- 
David Dorward                                      http://dorward.me.uk




More information about the Javascript mailing list