473,320 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to calculate the height of a text?

Hi,

I use dynamic menus and would like to know how I can figure out the height
of a text (for exalple "Product"). I need it to calculate text positions.

Zsolt
Jul 20 '05 #1
3 11942
Zsolt Koppany wrote on 18 nov 2003 in comp.lang.javascript:
I use dynamic menus and would like to know how I can figure out the
height of a text (for exalple "Product"). I need it to calculate text
positions.


IE:

<div id=Product
style="width:1px;height:1px;padding:0;font-size:21pt;"
onclick="alert(this.clientHeight+' px height')">
Product</div>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
Evertjan,

thank you for the answer.

Do you have a function that for example gets a string as an input parameter
and calculates the height of the string with a specific font?

Zsolt
"Evertjan." <ex**************@interxnl.net> schrieb im Newsbeitrag
news:Xn********************@194.109.133.29...
Zsolt Koppany wrote on 18 nov 2003 in comp.lang.javascript:
I use dynamic menus and would like to know how I can figure out the
height of a text (for exalple "Product"). I need it to calculate text
positions.


IE:

<div id=Product
style="width:1px;height:1px;padding:0;font-size:21pt;"
onclick="alert(this.clientHeight+' px height')">
Product</div>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 20 '05 #3
Zsolt Koppany wrote on 18 nov 2003 in comp.lang.javascript:
"Evertjan." <ex**************@interxnl.net> schrieb im Newsbeitrag
news:Xn********************@194.109.133.29...
Zsolt Koppany wrote on 18 nov 2003 in comp.lang.javascript:
> I use dynamic menus and would like to know how I can figure out the
> height of a text (for exalple "Product"). I need it to calculate
> text positions.

<div id=Product
style="width:1px;height:1px;padding:0;font-size:21pt;"
onclick="alert(this.clientHeight+' px height')">
Product</div>

Do you have a function that for example gets a string as an input
parameter and calculates the height of the string with a specific
font?


[please do not underquote on usenet]

<div id=Test
style="position:absolute;visibility:hidden;height: 1px;">x
</div>

<SCRIPT>
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>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a...
1
by: bin_P19 P | last post by:
the code i have got is as follows and now im stuck <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping...
1
by: Robert de Ridder | last post by:
I use an asp page to display pages, where the dynamic content is in an iframe. To calculate the height of the iframe I use the calcheight function. However when trying to do this with external...
0
by: Derrick | last post by:
I'm trying to calculate the height of a context menu in a manner that will work in both the full framework (where the calculation is easier because of the MeasureItem event of a MenuItem) and the...
1
by: comp.lang.php | last post by:
Sorry folks, I'm on a roll!!! I need to calculate the height or width of an image if you change either the width or height and don't change BOTH of them at the same time, this is to "vector" the...
12
by: paii, Ron | last post by:
Sorry about that last one. Does anyone know how to calculate the width a string of text for given Font name and size? I want to buildup a block of text strings to display in a unbound control,...
4
by: Rich_C | last post by:
I'm sure this is very simple, but I have very little experience with javascript -- and what I do know isn't helping me here. I have a simple form where users can enter a quantity (qty) and cost...
7
by: GD1 | last post by:
Dear developers, is there any way I can calculate the height in millimeters of a font at a certain size? Thank you in advance.
1
by: chockalingamn | last post by:
<html> <head> <script language="javascript"> var i=0,ta="T",qa="Q",ra="R",k=0.0,j=0.0; function addRowToTable() { var tbl = document.getElementById('ad'); var lastRow = tbl.rows.length -...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.