cufon和cufontext标签内的文本的负getboundingClientRect值。如何获得该文本的正面getboundingClientRect?

时间:2013-07-11 06:33:02

标签: javascript html cufon

我的代码在下面......

 <cufon class="cufon cufon-canvas" alt="John " style="width: 59px; height: 24px;">
   <canvas width="76" height="25" style="width: 76px; height: 25px; top: 0px; left: -1px;"></canvas>
<cufontext>
      <cufon class="cufon cufon-canvas" alt="John " style="width: 5px; height: 1px;">
      <canvas width="6" height="2" style="width: 6px; height: 2px; top: 0px; left: 0px;"> </canvas>
             <cufontext>John </cufontext>
  </cufon>
</cufontext>

我需要获取正确的boundingClientRect对象..

我正在尝试下面的代码,但它给了rect.left和rect.right的负值..

if(documentNode.createRange){

 var range = documentNode.createRange();

 range.selectNodeContents(textNode);

 if (range.getBoundingClientRect)
 {
        var rect = range.getBoundingClientRect();

        if (rect)
        {

                            y = rect.top;
                            h = rect.bottom - rect.top;
                            w = rect.right - rect.left;
                            x = rect.left;
                    }
            }
    }

请帮助

0 个答案:

没有答案