Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top