Bogdan Posted May 19, 2011 Share Posted May 19, 2011 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 Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 19, 2011 Administrators Share Posted May 19, 2011 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. Quote Link to comment Share on other sites More sharing options...
Bogdan Posted May 19, 2011 Author Share Posted May 19, 2011 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. Quote Link to comment Share on other sites More sharing options...
thecrgrt Posted May 19, 2011 Share Posted May 19, 2011 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 Quote Link to comment Share on other sites More sharing options...
elGringo Posted April 3, 2018 Share Posted April 3, 2018 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; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.