I'm not sure about offsetWidth (I never used it). But to get the
length in pixels you can use the idealBoundingRect attribute from the
edit element. See the 5.5 release notes for an example. Basically you
create an invisible edit field with the same font, size and attributes
like your link. Then set the value to the text you want to get the
width in pixels for. Using idealBoundingRect you can then read the
needed width of the text.

Hope this helps,
Benjamin

On Dec 25, 10:07 pm, whatsinthename <[email protected]> wrote:
> 1) when is the offsetWidth property set? I have the following code
> here as an example, I cannot explain why this behavior is happening.
> Look at the comments for details.
> -----------------------------------------------------------------------
> ------main.xml-----
> <view width="200" height="25" resizable="false"
> showCaptionAlways="true" onopen="onOpen();">
>    <script src="main.js"/>
>     <div name="mq" background="#ffffff" width="200" height="100%" />
> </view>
>
> ------main.js-------
>
> function onOpen(){
>   debug.trace('Loaded');
>   var RSSItem = "A RSS Feed";
>   var xmlString1 = "<a name = 'link1' align='left' href=" + 
> "'http://www.google.com'" + ">"+RSSItem+"</a>";
>   mq.appendElement(xmlString1);
>   debug.trace(mq.children("link1").offsetWidth); // this prints 0
>   fixlengths();
>   marqueeint = view.setInterval('Animate();',50);
>
> }
>
> function fixlengths(){
>   debug.trace(mq.children("link1").offsetWidth);  //again outputs 0
>
> }
>
> function Animate(){
>   debug.trace(mq.children("link1").offsetWidth);  //this outputs 60
> repeatedly
>
> }
>
> ------------------------------------------------------------------------
>
> 2) What I am trying to do is fill a div with a link objects. The
> problem is I do not know the size of individual link objects in pixels
> so I can set the width of the div dynamically. Eventually I want to
> concat all the titles of a RSS feed into one long line of text and
> have a div big enough to hold hem, and know the width of that div. Any
> ideas?
>
> Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Desktop Developer Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Desktop-Developer?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to