我在动态创建的DIV元素上使用Mootools更多函数“ getComputedSize”。它在Firefox中正常工作,但在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); 

结果是FF中的“ 150”,但在Chrome中,结果是“ NAN”。

有谁知道如何在Chrome中解决此问题,而不必将DIV编码为HTML?

提前致谢

亚历克斯

固定的:

this.resultBox = new Element('div', {
    'class': 'resultBox'
});

this.resultBox.inject(this.container, 'top');

console.log(this.resultBox.getComputedSize().width); 

在尝试使用此方法之前注入元素。

有帮助吗?

解决方案

固定的:

this.resultBox = new Element('div', {
    'class': 'resultBox'
});

this.resultBox.inject(this.container, 'top');

console.log(this.resultBox.getComputedSize().width); 

在尝试使用此方法之前注入元素。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top