On Dec 4, 10:36 pm, fma <f...@gbiloba.org> wrote: > Ok, I found something... > > If I look at the HTML tree in the IE debugger, on the left panel I > can't see any 'class' attribute. However, it does appear on the right > panel (called Attributs), with the correct value. But IE does not > seems to use it. I found that I can add an attribute to the div in the > left panel. So I tried to add an attribute named 'class', and I set > its value: this fixes the problem, and IE can apply the CSS!!! > > Then, I tried something else... I used the old-style to build the DOM > tree: > > this.content = document.createElement('div'); > Element.extend(this.content); > this.content.setAttribute('id', this._name + "_content"); > this.content.setAttribute('class', "fullContent"); > document.body.appendChild(this.content); > I don't know if this is relevant to the problem, but you don't need to use 'setAttribute' for built-in attributes of HTML element:
this.content.id = this._name + "_content"; avoids an unnecessary function call. For the DOM attribute 'class', the Javascript binding requires you to use 'className', because 'class' is a reserved word in Javascript: this.content.class = "fullContent"; (or, using a Prototype method) this.content.addClassName('fullContent'); This is not quite the same, because if you already have a class on the element, this will add the new class, whereas the simple assignment will replace it. But since you have just created the element, there is no difference. > instead of the new-style: > > this.content = new Element('div', {'id': this._name + "_content", > 'class': "fullContent"}); > > and it worked!!! > > At first, I didn't put the quotes arround the attributes names, in the > hash: > > this.content = new Element('div', {id: this._name + "_content", > class: "fullContent"}); > > but IE does not like this syntax (it asks for an int or a string). But > as you can see, giving a string does not seems to work well. IE objects (correctly) to your using the Javascript reserved word 'class' as an object key: Firefox is more lax and lets it through. 'id' will work without quotes. > > Am I doing something wrong with the new-style method? Or is it a known > issue in Prototype? > I don't know. Your example seems to match that in the Prototype documentation. I would try it with 'className' instead of 'class' and see whether this works. -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.