문제

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 ?

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top