faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 12 people (8%) answered Yes
Recently 1 of 10 people (10%) answered Yes


How can you determine the width in pixels a string will occupy on screen?

Apr 6th, 2008 19:43
ha mo, Colin Fraser, Thomas Junge,

On second thought, I put the same problem in a page I am thinking of
developing for an Intranet, so without thought I just did the obvious. I
did it in graphics, not one graphic, but three. The leading edge of the
tab graphic (LE), the text visual cue graphic VC), the trailing edge of
the tab graphic, (TE). So the images are lined up LE,VC1,TE, then
LE,VC2,TE, and so on. The LE is the same in all the tabs, the TE is the
same in all the tabs, only the VQ changes to suit the needed text. To
refine this a little more, the first LE and last TE may be different
than the LEs and TEs inside the tabs structure, but that is a simple issue. 
Obviously details will be needed to be ironed out, and I am sorry, I
just will not have time to draw the tabs, or the visual cues, and show
you what I mean but the VCs will be subject to normal rollovers and so
on. How you set this up, say inside a DIV with a number of other DIVs
which rollover or have their visible property changed to suit the VC is
entirely up to you, you may even want to use borderless frames in this
way several limitations can be overcome, including the variable nature
of screen resolutions and without worrying about font sizes, faces or
I should have thought of this before but it is so simple that I 
overlooked it, sorry. Anyway, I hope this offers an alternate solution.