Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > get the actual with and height of a document's content

Reply
Thread Tools

get the actual with and height of a document's content

 
 
juergen.riemer@chello.at
Guest
Posts: n/a
 
      04-16-2006
Hi all,

I want to get the actual dimensions of a document's content, not the
body's width/height. I want to do this to be able to resize an iframe
element in which this document resides to exactly the dimensions of the
text/content of this source.
My quick hack would be the code below, but it seems to be somewhat
wild.. is there a more elegant way to solve this problem?

greetz

mord
----

<html>
<head>
<script>
onload = function(){
var oBodyContent = document.body.innerHTML;
var oWrapper = document.createElement("DIV");
oWrapper.style.position = "absolute";
oWrapper.style.top = "0px";
oWrapper.style.visibility = "hidden";
var oTable = document.createElement("TABLE");
var oTBody = document.createElement("TBODY");
var oTRow = document.createElement("TR");
var oTData = document.createElement("TD");
oTRow.appendChild(oTData);
oTBody.appendChild(oTRow);
oTable.appendChild(oTBody);
oWrapper.appendChild(oTable);
document.body.appendChild(oWrapper);
oTData.innerHTML = oBodyContent;
alert(oTable.offsetWidth+' '+oTable.offsetHeight);
oWrapper.parentNode.removeChild(oWrapper);
}
</script>
</head>

<body>
blafasel <br>
blafasel <br>
blafasel <br>
</body>
</html>

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      04-16-2006
wrote:

> I want to get the actual dimensions of a document's content, not the
> body's width/height. I want to do this to be able to resize an iframe
> element in which this document resides to exactly the dimensions of
> the text/content of this source.


No, you do not want that.

However, you will recognize that even if the displayed resource is not
markup, HTML markup is used by browsers to display the content. So there
is always a `html' and a `body' element.

> My quick hack would be the code below, but it seems to be somewhat
> wild.. is there a more elegant way to solve this problem?


<URL:http://www.quirksmode.org/viewport/compatibility.html>


PointedEars
 
Reply With Quote
 
 
 
 
optimistx
Guest
Posts: n/a
 
      04-16-2006

"Thomas 'PointedEars' Lahn" <> kirjoitti viestissä
news:...
> wrote:
>
> > I want to get the actual dimensions of a document's content, not the
> > body's width/height. I want to do this to be able to resize an iframe
> > element in which this document resides to exactly the dimensions of
> > the text/content of this source.

>
> No, you do not want that.

....

I think I wanted to dimension an iframe to accommodate the contents without
scrollbars. But alas, somebody knows, that I did not want that...

I want to draw a circle with three corners. I want that.


 
Reply With Quote
 
blueapricot416@gmail.com
Guest
Posts: n/a
 
      04-16-2006
Another successful usenet posting!

Three cheers to anonymous help and the power of newsgroups!

 
Reply With Quote
 
juergen.riemer@chello.at
Guest
Posts: n/a
 
      04-17-2006
> I think I wanted to dimension an iframe to accommodate the contents without
> scrollbars. But alas, somebody knows, that I did not want that...


Your are right, I do not want to but was given a task by my supervisor.
Scrollbars are not an option for this application (eventhough it is B2B
with a defined system there would be other options I'd like more)

> I want to draw a circle with three corners. I want that.


Really do you want to? This would be an interesting academic question,
same might go with my initial problem..

Thanks in any case

greetz

mord

 
Reply With Quote
 
juergen.riemer@chello.at
Guest
Posts: n/a
 
      04-17-2006
As for me wanting to do this.. I was given the order to find a solution
(for an intranet app, defined system).

To get the according height is not of a problem, but how to get
information on the width? Any idea more elegant than the existing?

BTW: Thanks for the link, PPK is in my bookmarks for years though

greetz

mord

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz ASP .Net 6 06-09-2010 01:54 PM
Calculating the actual content width or height r_honey Javascript 23 12-22-2008 02:14 AM
How to get actual <td> height after displaying (rendering) Netx Javascript 8 12-13-2008 08:08 AM
How to get actual width and height of body ? Pugi! Javascript 5 06-15-2007 07:59 PM
how to get specific cell height without hard-coding a height value laredotornado@zipmail.com HTML 0 08-19-2006 08:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57