2

我在动态创建的 DIV 元素上使用 Mootools More 函数“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); 

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

4

1 回答 1

1

固定的:

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

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

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

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

于 2010-11-26T16:30:08.060 回答