Windows小工具字体错误

时间:2010-01-18 18:05:13

标签: windows windows-desktop-gadgets

我在Windows 7中编写了一个补充工具栏小工具,并添加了一个g:textObject,稍后通过variable.value更改了该值。

但是在Windows Vista中运行时,文本看起来很奇怪。

这段代码有什么问题吗?

var clock = document.getElementById("background").addTextObject("Time", "Nyala", 18, "white", 110, 500);
//This correctly displays the word 'Time' in the proper font.

clock.value = clock.value+"s";
//This causes the text to become "Times" but shrink.
//appending more sporadically causes the textObject to shrink as well.

使用.value的方法是错误的吗?

1 个答案:

答案 0 :(得分:1)

更改文本字符串不会更新g:文本对象的宽度或高度。这是一个已知问题,出于兼容性目的,可能无法修复。您必须手动重置宽度和高度才能更改值:

var clock = document.getElementById("background")
    .addTextObject("Time", "Nyala", 18, "white", 110, 500);

// Set the new value and reset the width and height by setting them to 0
clock.value  = clock.value+"s";  
clock.width  = 0;
clock.height = 0;