Also what is meant by the document height?
The height of the html element?
I'm searching for a to find the actual height of a document (not the
html element, which can have a smaller height than the document).
Is there a way with regular dom methods?
Regards,
Martijn
Maybe something like this should work?
var height =
document.defaultView.getComputedStyle(document,'-moz-canvas').getPropertyValue("height");
This isn't allowed since getComputedStyle only accepts elements, not
document.
MartijnW wrote:
> See:
> http://www.mozilla.org/docs/dom/domref/dom_doc_ref20.html
> I tried setting the document.height, but I get an error ("setting a
> property that only has a getter" or something like that.
> So, I think the documentation is false.
With Netscape 4 you could set document.height (and you had to if you
wanted your dynamically created layers to show up) but I don't think it
was ever possible to set document.height in Mozilla.
> Also what is meant by the document height?
I think it is the height of the canvas.
--
Martin Honnen
http://JavaScript.FAQTs.com/
So that documentation needs to be fixed.
>> Also what is meant by the document height?
>
>
> I think it is the height of the canvas.
I don't think so, consider this testcase:
<html style="height:100px;"><head></head>
<body style="height:50px;">
<button onclick="alert(document.height)">doe</button>
<div
style="position:absolute;top:50px;height:2000px;width:50px;border:2px
solid red;"></div>
</body>
</html>
This alerts 50 for me in current trunk build.
Regards,
Martijn
MartijnW wrote:
> Martin Honnen wrote:
>
>
>>> Also what is meant by the document height?
>>
>>
>>
>> I think it is the height of the canvas.
>
>
> I don't think so, consider this testcase:
>
> <html style="height:100px;"><head></head>
> <body style="height:50px;">
> <button onclick="alert(document.height)">doe</button>
> <div
> style="position:absolute;top:50px;height:2000px;width:50px;border:2px
> solid red;"></div>
> </body>
> </html>
>
> This alerts 50 for me in current trunk build.
It seems
document.documentElement.scrollHeight
gives the height of the canvas but I think document.height should also
give that, looks like a bug to me.
Wait a minute, I mean with the canvas, what is said here:
http://www.w3.org/TR/CSS21/intro.html#q4
It seems like you interpret the canvas as the root element.
document.documentElement.scrollHeight returns 100 to me, but I want the
'real' document height (2054 as it seems).
Regards,
Martijn
Which is defined to have infinite extent....
-Boris
Regards,
Martijn
And if this is smaller than the viewport then you don't want it increased to the
viewport height, right?
-Boris
Try it with this example (document.documentElement.offsetHeight won't
give the value I/you want):
<html><head></head>
<body>
<div
style="position:absolute;height:2000px;top:0;background-color:green;">test</div>
<button onclick="alert(window.innerHeight+window.scrollMaxY)">doe</button>
</body>
</html>
Regards,
Martijn