I am using the Mootools More function "getComputedSize" on a dynamically created DIV element. It works fine in Firefox but not in Google Chrome:
CSS:
.resultBox {
width: 150px;
height: 100px;
position: absolute;
z-index: 1000;
}
Javascript:
this.resultBox = new Element('div', {
'class': 'resultBox'
});
console.log(this.resultBox.getComputedSize().width);
The result is "150" in FF but in Chrome the result is "NaN".
Does anyone know how to fix this in Chrome without having to code the DIV into the html开发者_StackOverflow ?
Thanks in advance
Alex
Fixed:
this.resultBox = new Element('div', {
'class': 'resultBox'
});
this.resultBox.inject(this.container, 'top');
console.log(this.resultBox.getComputedSize().width);
Inject the element before trying to use this method.
Fixed:
this.resultBox = new Element('div', {
'class': 'resultBox'
});
this.resultBox.inject(this.container, 'top');
console.log(this.resultBox.getComputedSize().width);
Inject the element before trying to use this method.
精彩评论