Auto-Refresh Windows Sidebar Gadget Example

It’s silly how trivial a thing like grabbing a webpage’s content every minute and displaying it in a Sidebar gadget is. Granted, my knowledge of JavaScript and the like is limited to some basic functions (and mostly Google searches) but still..

What I wanted to do is have a sidebar gadget that grabs a page’s content every minute and displays it. First I tried with regular JavaScript without any luck. I moved on to the more familiar jQuery library and got it to work after a while. The main problem was the IE engine of the Sidebar caching the pages. To bypass this I just pass along the Unix timestamp in the URL.

So.. after messing around for a while, especially since it worked after 1 minute in a regular webbrowser and having barely to none capabilities to debug a sidebar gadget, here’s the working code:

<html>
<head>
	<title>SVO Status</title>
	<style>
		body{width:128;height:15}
    body{font-family:"Verdana", sans-serif;}
    body{font-size:11px;}
    body{margin:5px 2px 2px 2px;}
    body {background-color:#b0c4de;}
 
	</style>
<script language="javascript" src="jquery.js"></script>  
<script type="text/javascript">
jQuery.support.cors = true;
 
var refreshId = setInterval( function()
    {
      var seconds = new Date().getTime();       
      var url = "http://svo.skyon.be/s.php?cache=" + seconds;
      $.get(url, function(data) {
      $("#result").html(data);
       });
    }, 60000);
</script>  
 
 
  </head>
<body>
<div id="result"></div>
</body>
</html>

This excludes the gadget.xml file, which of course has to be added as well as the jQuery library.

I didn’t find any ready-made result out there so hopefully this post can help anyone who would like to make a simple status-fetching gadget.