[英]Windows 7 gadget not loading
I'm developing a simple gadget for Windows 7 as a learning exercise.我正在为 Windows 7 开发一个简单的小工具作为学习练习。 I read in this article (under the subtopic Gadgets and Script ) that to initialize the gadget, you should use
document.onreadystatechange
instead of events such as onLOad
.我在这篇文章(在子主题小工具和脚本下)中读到,要初始化小工具,您应该使用
document.onreadystatechange
而不是onLOad
等事件。 I've seen it in the example project code I've looked through as well.我也在我浏览过的示例项目代码中看到了它。 This is what I came up with for my project.
这就是我为我的项目想到的。
document.onreadystatechange = function()
{
if(document.readyState == "complete")
{
System.Gadget.settingsUI = "settings.html"; //this line enables the settings UI
System.Gadget.onSettingsClosed = settingsClosed;
}
}
However when I use this snippet in my work, it doesn't work.但是,当我在工作中使用此代码段时,它不起作用。 The Options button in the gadget doesn't show up.
小工具中的“选项”按钮未显示。 If I use
onLoad
, it works.如果我使用
onLoad
,它会起作用。 I have installed 2 gadgets.我已经安装了 2 个小工具。 Each of them use these 2 methods.
他们每个人都使用这两种方法。 One use
onLoad
and the other use document.onreadystatechange
.一个使用
onLoad
,另一个使用document.onreadystatechange
。 And both of them works!他们两个都有效!
Now I'm confused why it doesn't work with my gadget.现在我很困惑为什么它不适用于我的小工具。 Is there any important part I'm overlooking?
我忽略了任何重要的部分吗?
try something along these lines, move your onsettingsclosed
to a different event and call the function with it沿着这些方向尝试一些事情,将您的
onsettingsclosed
移动到另一个事件并用它调用 function
document.onreadystatechange = function()
{
if(document.readyState=="complete")
{
var searchTags = System.Gadget.Settings.read("searchTags");
if(searchTags != "")
{
searchBox.value = searchTags;
}
}
}
System.Gadget.onSettingsClosing = function(event)
{
if (event.closeAction == event.Action.commit)
{
var searchTags = searchBox.value;
if(searchTags != "")
{
System.Gadget.Settings.write("searchTags", searchTags);
}
event.cancel = false;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.