Domanda

I'm new with Windows gadgets and I need some help. I want to make gadget which show some information from network (game server status). I already achieved this with PHP, but we know gadgets does not support PHP. I googled but didn't find anything similar to "fsockopen" in JavaScript. So I decided to make picture from status and saved it to PNG. Gadget loaded it successfully but when I'm trying to update image it wont change. Every time I change picture and use "localhost/610status.png" url it open some old picture from some kind of cache. Same code works perfectly with firefox.

Here are necessary parts of my gadget code:

<script type="text/javascript" language="javascript">
      //var a=0;
      function init()
      {
            //document.getElementById("status").src="images/1.png";
            document.getElementById("status").src="http://localhost/610status.png";
            //document.getElementById("gadgetContent").innerHTML = a;
            //a+=1; //for testing timeout
            setTimeout("init()", 6000);
      }
</script>
</head>
<body onload="init();">
      <img id="status" src="images/1.png"  />
</body>

As you see from comments I tested for sure that timeout and onload things will work. Maybe there are easier ways to do this, but I'm not very familiar all those JavaScript and Windows gadgets possibilites. What would fix this is to force gadget to reload image, but how to do it?

È stato utile?

Soluzione

Break the cache by using a unique URL:

"http://localhost/610status.png?now=" + new Date()
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top