开发者

Mootools getComputedSize not working in Chrome

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜