Prototype.js 1.6 new element class and IE> = 9

Then I try to create a new item like

new Element('div',{'class':'name'});

      

all browsers create a new element with the class name. But in Internet Explorer 9 and 10 I have this

<div className="name"></div>

      

As you can see, a className attribute is created instead of a class. How can I fix this?

+3


source to share


3 answers


//This generates 'className':
var popoutControl = new Element('div', {'class':'mySuperCoolClassName'});

// Break the line up into two lines. 
// The following will generate a 'class' attribute instead:
var popoutControl = new Element('div');
popoutControl.className = 'mySuperCoolClassName';

      



+3


source


replace

new Element('div',{'class':'name'});

      

from



var mydiv = new Element('div');
mydiv.addClassName('name');

      

As suggested by http://prototypejs.org/api/element/classNames Element. Class name ('name'); is deprecated and you must use Element. addClassName ().

0


source


Please see my answer here:

fooobar.com/questions/1899256 / ...

Basically, prototype 1.6 doesn't work in these versions of IE. You should update Prototype. the problem is in the list of translations contained in Element._attributeTranslations.write

Object Element._attributeTranslations.write in Prototype 1.6.0.3

This is the list in prototype 1.7 (and up I suppose)

Element._attributeTranslations.write in Prototype 1.7+

I am assuming it worked in older versions of IE (this was probably the case before IE9).

0


source







All Articles