简体   繁体   中英

Windows 7 gadget not loading

I'm developing a simple gadget for Windows 7 as a learning exercise. 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 . 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. I have installed 2 gadgets. Each of them use these 2 methods. One use onLoad and the other use 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

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;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM