1

我在 Windows 7 中编写了一个侧边栏小工具,并添加了 ag: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 是错误的方法吗?

4

1 回答 1

1

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

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;
于 2010-01-19T14:21:23.707 回答