Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] is their a javascript function, or DOM propertyto find the char limit of a table cell or div?
- From: john at jwarner.com (John Warner)
- Subject: [Javascript] is their a javascript function, or DOM propertyto find the char limit of a table cell or div?
- Date: Wed Jan 31 10:49:13 2007
In most server side languages there are tools/functions that can give you the font metrics (size, width & height etc). Well let me say that's been my experience in Winders. Are there any similar functions available to JavaScript or that CSS can make available. If you know this the rest is easy, just math. But note this shows my ignorance regarding JavaScript, I've no idea if such a thing exists. The browser has this information somewhere, but is it exposed to 'us'? John Warner > -----Original Message----- > From: javascript-bounces@xxxxxxxxxx > [mailto:javascript-bounces@xxxxxxxxxx] On Behalf Of tedd > Sent: Wednesday, January 31, 2007 10:51 AM > To: [JavaScript List] > Subject: Re: [Javascript] is their a javascript function, or > DOM propertyto find the char limit of a table cell or div? > > > At 4:24 PM +0000 1/30/07, Lee Bettridge wrote: > > was wondering if their is a way to find out how many characters > >will fit into an area of a given size ? > > > Lee: > > I had the same problem. The width and height of the viewing area (the > frame) is not a problem, you can get that from the window attributes. > The problem is number of characters and linefeeds that are contained > in the body of the text and how much of that you can display in the > frame allotted. > > I started by reading in the text and building the amount I could > display in the frame by counting characters and upon reaching the > maximum width would then increment a line count. When I reached a > linefeed, I would simply increment the line count and move on. When > the maximum number of lines was reached, I was done. > > I took my example a bit further by ending text at paragraphs and thus > slightly less than what was allotted. I don't like dangling paragraph > remnants. > > The code I have is in php and very specific to my example so > providing it would cause you more headache than working it out > yourself, but I've given you the basics. It's not that much of a > problem to figure out. > > hth's > > tedd
- References:
- Prev by Date: [Javascript] is their a javascript function, or DOM property to find the char limit of a table cell or div?
- Next by Date: [Javascript] please test before posting [WAS: Re: INPUT TEXT show last characters]
- Previous by thread: [Javascript] is their a javascript function, or DOM property to find the char limit of a table cell or div?
- Next by thread: [Javascript] Database and SQL
- Index(es):