S
Simon Wigzell
I am adapting a javascript pulldown menu system to my dynamic website
generator - the arrays that hold the menu items information are read from a
database and will be different for different users of my system.
Unfortunately the javascript menu system requires that each menu cell's
width be dimensioned. if I don't hard code a large enough value then long
menu item names are trimmed, besides the fact that it then looks ugly for
most menu items that are much smaller than the hardcoded width. What I would
like to do is find the actual pixel width of a string which will have to
take into account the font, the character size, bold on or off, number of
characters and of course proportional font or not will make a difference
too...is there a way of determining in advance how wide in pixels a string
is going to be? e.g. if I set it to some hidden named html element with all
of its style properties, could I then retrieve the width of that element
with javascript? Thanks!
generator - the arrays that hold the menu items information are read from a
database and will be different for different users of my system.
Unfortunately the javascript menu system requires that each menu cell's
width be dimensioned. if I don't hard code a large enough value then long
menu item names are trimmed, besides the fact that it then looks ugly for
most menu items that are much smaller than the hardcoded width. What I would
like to do is find the actual pixel width of a string which will have to
take into account the font, the character size, bold on or off, number of
characters and of course proportional font or not will make a difference
too...is there a way of determining in advance how wide in pixels a string
is going to be? e.g. if I set it to some hidden named html element with all
of its style properties, could I then retrieve the width of that element
with javascript? Thanks!