Windows gadgets: how do I change the DOM?

I am working on a Windows Desktop gadget. I can create the HTML elements that I want using document.createElement. I can set their attributes, and I can get these attributes after setting them, but everything I do to change the document just fails completely silently. I don’t see any errors at all, but the gadget just does not change. Even that which simply document.body.innerHTML = "asdf";does absolutely nothing. The same code works fine in IE8. What am I missing here?

gadget.xml:

<?xml version="2.0" encoding="utf-8" ?>
<gadget>
<name>Citrix Logon Controller</name>
<version>0.1</version>
<author name="Brian G. Shacklett">
    <info url="http://digital-traffic.net" />
</author>
<copyright>&#169; Brian G. Shacklett</copyright>
<description>Controls Citrix Logons.</description>
<hosts>
    <host name="sidebar">
        <base type="HTML" apiVersion="1.0.0" src="gadget.html" />
        <permissions>Full</permissions>
        <platform minPlatformVersion="1.0" />
    </host>
</hosts>
</gadget>

HTML:

<html>
    <head>
    <title>Citrix Manager</title>
    <script type="text/javascript">
        debugger;
    </script>
    <script src="scripts/debug.js" type="text/javascript"></script>
    <script src="scripts/gadget.js" type="text/javascript"></script>
    <script src="scripts/util.js" type="text/javascript"></script>
    <link type="text/css" rel="stylesheet" href="styles/gadget.css" />
</head>

<body >
    <div id="header"><h1>Citrix Manager</h1></div>
    <div id="mainContent">
        <a href="#" onClick="window.location.reload()">reload</a><br />
        <a href="#" onClick="testFunction();">New Server</a>
    </div>
</body>
</html>

gadget.js:

function testFunction()
{
document.body.innerHTML = "asdf";
}
+3
source share
1 answer

, innerHTML onclick . .

document.body.innerHTML = "asdf"; window.prompt("","");. , :

function testFunction() 
{
    window.prompt("", "");
    // window.prompt("", document.body.innerHTML);    // before
    document.body.innerHTML = "asdf";
    // window.prompt("", document.body.innerHTML);    // after
} 

/, innerHTML (. ).

-, , . Vista System.Gadget.beginTransition() , System.Gadget.endTransition(). , endTransition() .

System.Gadget.beginTransition();
blah = blah.blah.blah.blah;         // "blah" is null or not an object
System.Gadget.endTransition(System.Gadget.TransitionType.morph, 1.0);

try/catch , . , DOM, (prompt) .


UPDATE

. , return false;, :

   <a href="#" onClick="testFunction(); return false;">New Server</a> 

innerHTML "#". , , # , , . .

+1

Source: https://habr.com/ru/post/1733452/


All Articles