Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
let's assume you can use a font which renders exactly the same in all browsers and is per default installed on all OSes...

You can use Javascript to determine the pixel length of this font!

E.g. by reading the coordinates of embracing links, this already worked with Netscape4-"DOM" and I used it this way to get font-width.

So just send a HTML-Page to your browser with the font and the JS and read out the results.

You can do it via a webserver and a form-submit (or AJAX's XmlHttpRequest) with the results or even by remotely telling a local Firefox to load and save the (enriched) local webpage (-remote option)

Cheers Rolf

UPDATE: Should even be possible to send the JS-Code via telnet to a MozRepl AddOn in FF.

NOTA BENE:This solution implies at least one running webbrowser, but gives you real control and testing over the resulting page.

UPDATE2: Well seems NS4 was also the last browser to support link-coordinates, but I'm sure that standard DOM has even much richer possibilities. ... indeed style.left, style.top or offsetLeft, offsetTop


In reply to Re: Pixel length of strings (Javascript+DOM) by LanX
in thread Pixel length of strings by TruthSeeker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-29 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found