Find the table height?

C

Charley Kyd

In FrontPage Design view there are two ways to change the height of a table.
We can specify a height property, or we can add a lot of text in a cell to
force the table to expand vertically.

My program uses the second approach by writing data to a cell. Is there a
programmatic way to find the actual height of the table, not merely the
height specified in Table Properties?

Thanks.

Charley
 
S

Stefan B Rusynko

Table heights are minimums
- adjusted by content to expand (cells and typed content)
- not supported by some browsers

The only way to specify it (if you really need to) is w/ table properties




| In FrontPage Design view there are two ways to change the height of a table.
| We can specify a height property, or we can add a lot of text in a cell to
| force the table to expand vertically.
|
| My program uses the second approach by writing data to a cell. Is there a
| programmatic way to find the actual height of the table, not merely the
| height specified in Table Properties?
|
| Thanks.
|
| Charley
|
|
|
 
M

MD Websunlimited

Charley,

I assume you mean the height of the table that has been expanded with content:

document.getElementById("table1").offsetHeight

Where table1 is the id of the table in question. Works in IE 4> and NS 6>

Please note that there are minor variations with respect to borders and padding among various operating system versions of IE and
compatibility modes controlled by the DOCTYPE declaration. The trend is to include the measure of the borders and padding but not
the margins

HTH,

--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
J-Bots Plus 2002 87 components for FrontPage
http://www.websunlimited.com/order/Product/JBP2002/jbp_help_dir.htm
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
 
C

Charley Kyd

Mike,

In the first page I tried them with,.offsetHeight and .clientHeight gave the
same results. What's the difference between them? When would their values
differ?

Thanks.

Charley


MD Websunlimited said:
Charley,

I assume you mean the height of the table that has been expanded with content:

document.getElementById("table1").offsetHeight

Where table1 is the id of the table in question. Works in IE 4> and NS 6>

Please note that there are minor variations with respect to borders and
padding among various operating system versions of IE and
compatibility modes controlled by the DOCTYPE declaration. The trend is to
include the measure of the borders and padding but not
 
C

Charley Kyd

I've got a related problem that I'm hoping you could help me with. I've got
code like:

With tbMain
.Height = .clientHeight
If .Height <> .clientHeight Then Stop
.Height = .clientHeight
End With

(tbMain is dimmed as FPHTMLTable.)

The Stop is necessary because setting the height doesn't always work the
first time. But after the Stop I can step through the next line and it
always works. Is there a way to force FrontPage to get it right the first
time?

I've tried putting in a loop with an Application.Wait. I've tried adding
DoEvents to the loop. But nothing seems to work.

Any suggestions?

Thanks.

Charley

MD Websunlimited said:
Charley,

I assume you mean the height of the table that has been expanded with content:

document.getElementById("table1").offsetHeight

Where table1 is the id of the table in question. Works in IE 4> and NS 6>

Please note that there are minor variations with respect to borders and
padding among various operating system versions of IE and
compatibility modes controlled by the DOCTYPE declaration. The trend is to
include the measure of the borders and padding but not
 
M

MD Websunlimited

Hi Charley,

offsetHeight is the height of the object relative to the layout or coordinate parent, as given by the offsetParent property. That is
the formal definition the informal one is that it contains the height including borders and padding widths.

clientHeight is the height of the object without taking into account any margin, border, scroll bar, or padding that might be
applied to the object. In NS 7 this value is zero except when the element container overflows the viewable area, in which case they
contain the size of the viewable area.

So if you have no border or padding then they would be the same.

HTH,



--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
Create fast, better scaling link bars with CSS Menu Maker
http://www.websunlimited.com/order/Product/CssMenu/css_menu.htm
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
 
M

MD Websunlimited

Charley,

As you've learned FP does not always update the document - abnormality started in FP 2002 and continues in FP 2003. It was reported
under FP2 beta.

To make the code work, provided you do not intend to support FP 2000 you can grab the document object and write it back to force the
update.

if not ActiveDocument is nothing then
ActiveDocument.DocumentHTML = ActiveDocument.DocumentHTML
else
msgbox "Please open a document to use this functionality", ...........
end if

HTH,

--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
Need to add Meta Tags to your web pages NOW with Google Bot controls.
http://www.websunlimited.com/order/Product/MTM2002/mtm2002_help_dir.htm
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
 
C

Charley Kyd

Mike,

Thanks for both replies. I'd like to clarify this one, however.

My core code is:
==============
''Size the <table>
With tbMain
.Height = .offsetHeight
End With

''Size the <td>
With tdLeftSide
.Height = .offsetHeight
End With

Etc.
==============
So, where would I add the code?:

With tbMain.Document
.DocumentHTML =.DocumentHTML
End With

Thanks.

Charley


MD Websunlimited said:
Charley,

As you've learned FP does not always update the document - abnormality
started in FP 2002 and continues in FP 2003. It was reported
under FP2 beta.

To make the code work, provided you do not intend to support FP 2000 you
can grab the document object and write it back to force the
 
C

Charley Kyd

Mike,

This is strange. With this code...

Dim tbMain As FPHTMLTable, pwCur As FrontPage.PageWindow
...
Set tbMain = pwCur.Document.all.Item("tbMain")
...

With tbMain.Document
.DocumentHTML = .DocumentHTML
End With

With tbMain
.Height = .clientHeight
End With

....both the clientHeight and the offsetHeight have the value of -1.

What am I doing wrong?

Thanks.

Charley


MD Websunlimited said:
Charley,

As you've learned FP does not always update the document - abnormality
started in FP 2002 and continues in FP 2003. It was reported
under FP2 beta.

To make the code work, provided you do not intend to support FP 2000 you
can grab the document object and write it back to force the
 
C

Charley Kyd

Note to File:

I haven't received an answer to the message below. But I think I've found a
way to fix the problem I described. The bug apparently occurs only when we
try to set the value of one property directly equal to that of another. But
if we use an intervening variable, the problem seems to go away.

(I know, "I think" and "apparently" and "seems to" don't offer a ringing
endorsement of this approach. But so far, it works.)

So, rather than this...
===================
With tbMain
.Height = .clientHeight
End With
===================

....format nHeight as an integer and use this...
===================
With tbMain
nHeight = .clientHeight
.Height = nHeight
End With
===================

Also, for some reason, all variations I tried of the following code -- code
suggested as a workaround -- destroyed the tbMain object. Therefore, it
isn't part of the solution. (The problem I had with this code probably
reflects my own mistakes. Used correctly, the code might work to fix this
bug.)
===================
With tbMain.Document
.DocumentHTML = .DocumentHTML
End With
===================

Charley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top