getComputedTextLength not implemented

为了解决svg将中文显示为乱码的问题,安装了renesis svg view 插件,ie的插件。

安装完后,能正确显示中文。但是带来另一个问题。

 代码中原有个功能是跟随鼠标,产生一个小的tooltip提示框,提示框中有文字,为了将文字放在提示框合适位置,用了一个函数

text.getComputedTextLength(),但是renesis插件不认识这个方法,总是提示operation not supported by implementation.

找了好久才发现是这句话出了问题。

怎么办呢?

网上google了半天,也没有发现解决办法。那就只有卸掉renesis,另外想办法解决中文问题了。

下面是一个人遇到的同样的问题。没人回答。

看来svg用的人不多。

 

In a little svg-file I want to insert tooltips moving with the pointer. Because of using object dependend text I'm going to calculate tooltip box length by using the function getComputedTextLength(). Looking at the current implementation status of SVG I find that getComputedTextLength() is not "unimplemented" for SVGTextElements.

But the JavaScript Console of Deer Park Alpha I (Gecko/20050609 Firefox/1.0+) shows an error: "ShortInfoText.getComputedTextLength() is not a function" I couldn't find out the real problem behind that message yet.

Here now comes a section of my script to make clear the context:
(with MaxLength I want to find the length for the box to show text)
(nearly needless to mention: adobe plugin is doing this as I expect it)

*******************
.
.
ShortInfoText = SVGDocument.createElement("text");
ShortInfoTextValue = SVGDocument.createTextNode("");
ShortInfoTextValue.nodeValue = "some text from somewhere";
ShortInfoText.setAttribute("style","font-size:"+Height);
ShortInfoText.setAttribute("x",8);
ShortInfoText.setAttribute("y",6 + (LineNumber*(Height+1)));
ShortInfoText.appendChild(ShortInfoTextValue);
if (ShortInfoText.getComputedTextLength() > MaxLength) {
MaxLength = ShortInfoText.getComputedTextLength ();
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值