user2284570
user2284570

Reputation: 3060

Get the height of a whole page in pixel

For some decoration, I need to insert an upper margin at the beginning of the document which represent 34% of the whole height of the page (margin included).
My page < body> start like this:

    <body bgcolor="#dedede" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="-webkit-text-size-adjust:none;">
        <tbody>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#dedede">
                <tr>
                    <td>
                        <table class="premier-tableau" width="600" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" align="center">
                        <thead>
                                <tr height="500" /> <!-- I need to use this line as a margin -->
                        </thead>
                        <tbody>
                            <tr>
                                <td width="35" />
                                <td width="530">
                                    <font color="#5e5e5e" face="Arial, Helvetica, sans-serif" size="2" style="font-size: 12px;">

This is for using in e-mails.

Of course it is possible to calculate manually the number of pixel, and add the static result to the < tr> tag. But, It is part of a semi-automated process, and I would like to avoid that.
Also note that the destination SMTP server may have a strict policy and refuse attachments. So, I don't see how to use externals libraries (such as JQuery). As a modern ecmascript is available, I would like to avoid using them...

Any embeddable solutions (css;javascript;svg ...) are accepted.

Upvotes: 1

Views: 1425

Answers (3)

user2284570
user2284570

Reputation: 3060

There is the viewports Units which have been designed for that. Few browser support it actually, but using height="34vh" will be the right way to proceed in some years.

It will take some years for clients to comply with the standard. An actual way to proceed now, is to compute the size (in px) manually each time the document is edited.

Upvotes: 0

zord
zord

Reputation: 4783

since you have no margins on the body, a simple height should do it.

document.getElementsByTagName("body")[0].height

Upvotes: 0

m59
m59

Reputation: 43755

document.body.parentNode.offsetHeight but - javascript isn't going to run in emails :) I therefore think that you need to do this manually.

Upvotes: 3

Related Questions