ReMaX
04-30-2008, 02:32 AM
Heyho,
I just put myself the question if it is possible to get the size of a DOM element that is not yet appended to the document. There is a content inside and normally the element resizes itself to the size of the content. How do I get this without placing it in the document, reading its size and deleting it?
example:
var element = document.createElement("div");
var element1 = document.createElement("div");
var textnode = document.createTextNode("Hello, you, I am a node!");
element1.appendChild(textnode);
element.appendChild(element1);
alert(element.offsetWidth); // of course, that does not work but how then
greetings
Max
I just put myself the question if it is possible to get the size of a DOM element that is not yet appended to the document. There is a content inside and normally the element resizes itself to the size of the content. How do I get this without placing it in the document, reading its size and deleting it?
example:
var element = document.createElement("div");
var element1 = document.createElement("div");
var textnode = document.createTextNode("Hello, you, I am a node!");
element1.appendChild(textnode);
element.appendChild(element1);
alert(element.offsetWidth); // of course, that does not work but how then
greetings
Max