動的に作成された 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" になります。
DIV を html にコーディングせずに Chrome でこれを修正する方法を知っている人はいますか?
前もって感謝します
アレックス
修理済み:
this.resultBox = new Element('div', {
'class': 'resultBox'
});
this.resultBox.inject(this.container, 'top');
console.log(this.resultBox.getComputedSize().width);
このメソッドを使用する前に要素を注入してください。