質問

動的に作成されたDiv要素で、Mootools More Function "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」になりましたが、クロムでは結果は「nan」です。

divをHTMLにコーディングすることなく、Chromeでこれを修正する方法を知っている人はいますか?

前もって感謝します

アレックス

修理済み:

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