Jump to content

Height for TUniHTML


Bogdan

Recommended Posts

Hi, Farshad!

 

Is there any way to get maximum used height for TUniHTMLFrame (something like TComponent.HorzScrollbar.Size) ?

 

Let me explain this. I have TuniHTMLFrame with Height 36 and property AutoScroll=True. Text in component has different length and I would to know, what is minimum Height for component to show all text without scrollbar. Is this possible ?

 

Regards

 

Bogdan

Link to comment
Share on other sites

  • Administrators

Hi, Farshad!

 

Is there any way to get maximum used height for TUniHTMLFrame (something like TComponent.HorzScrollbar.Size) ?

 

Let me explain this. I have TuniHTMLFrame with Height 36 and property AutoScroll=True. Text in component has different length and I would to know, what is minimum Height for component to show all text without scrollbar. Is this possible ?

 

Regards

 

Bogdan

 

Hi,

 

You can only get design time height of TUniHTMLFrame. Its variable HTML height can not retrieved.

Link to comment
Share on other sites

Hi,

 

You can only get design time height of TUniHTMLFrame. Its variable HTML height can not retrieved.

 

No, this is not what I need :). I saw that vertscrollbox indicator is different depending on length of text. This is what I need. I would like to increase height of UniHTMLFrame until the entire text is visible.

Link to comment
Share on other sites

No, this is not what I need :). I saw that vertscrollbox indicator is different depending on length of text. This is what I need. I would like to increase height of UniHTMLFrame until the entire text is visible.

Text height is come from various result, i.e. font name/family, fony size, etc.

You can use JavaScript to calculate a height of text.

 

<script language="javascript" type="text/javascript">
function TextHeight(text, points, family){
 test = document.getElementById("Test");
 test.style.fontFamily = family;
 test.style.fontSize = points;
 test.innerHTML = text;
 return test.clientHeight + ' px height';
}

alert("Arial: " + TextHeight("Product", "41pt", "Arial"));
alert("Verdana: " + TextHeight("Product", "41pt", "Verdana"));
</script>

or

<script language="javascript" type="text/javascript">
function getDivHeight(){
 alert("Client Height:  " + document.getElementById("div1").clientHeight);       
 alert("Offset Height:  " + document.getElementById("div1").offsetHeight);
}
</script>

<body>
 <center>
   <div id="div1">
       Get Div Height using Javscript function. Javascript DOM document can access the
       height of HTML Div element dynamically.
   </div>
   <br />   
   <input type="button" value="Get Div Height" onclick="getDivHeight()" />
 </center>
</body>

 

But again, how can we get value from JavaScript? maybe Farshad has an answer :)

Link to comment
Share on other sites

  • 6 years later...

hi, for future answers seekers! Has similar question, found solution with help of great Delphi Developer

 

this will just alert with heightInfo

js:='alert('+HTMLFrame.JSName+'.body.el.dom.scrollHeight);';
  UniSession.JSCode(js);

you can send it like this from client

 js := ' function getTextHeight()' + //
    '{' + //
    
    'return HTMLFrame.JSName+'.body.el.dom.scrollHeight' + //
    '}' + //
    'ajaxRequest(' + HTMLFrame.JSName + ', ''HTMLFrameHeightAdjust'', [ ''param0=''+getTextHeight(), ''param1=B'' ]);';
  UniSession.JSCode(js);

on Server accept like this

procedure TPaymentsPageContent.HTMLFrameAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  if SameText(EventName, 'HTMLFrameHeightAdjust') then  
    begin
    ShowMessage('Here ' + Params.Values['param0']);
    // do smth
    HTMLFrame.Height:=Params.Values['param0'].toInteger;
    end;
end;

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...