Need Help Refreshing My Gadget.

Hi, I'm almost finished with a gadget that shows a new "game of the hour" every 60 seconds. The thing is, is that I don't have a way to get it to refresh the gadget every 60 seconds. I've tried Meta tag refresh tags, java-script refresh tags, and a solution I found on these forums a little while ago, and nothing seems to be working. Any help would be appreciated.



Answer this question

Need Help Refreshing My Gadget.

  • arro239

    Sure I can post the code here:

    <html>
    <head>
    <title>Warning9.com Games</title>
    <script language="javascript" type="javascript">
    window.setInterval(updateData, 5);
    function updataData() {
    // Assign some values to elements
    myText.innerHTML = "New Text";
    }
    </script>
    </head>
    <body onload="updateData">
    <style type="text/css">
    body
    {
    width:130px;
    height:110px;
    margin:0px;
    padding:0px;
    }
    <!--
    .style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: bold;
    color: #000000;
    }
    .style2 {
    font-size: 10px;
    font-family: Arial, Helvetica, sans-serif;
    }
    .style3 {color: #000000}
    -->
    </style>
    <table width="130" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <th scope="col"><img src="/images/dailygame.gif" border="0"></th>
    </tr>
    <tr>
    <td background="/images/background.png"><span id="myText"><script language='JavaScript' type='text/javascript' src='http://warning9.com/ads/adx.js'></script>
    <script language='JavaScript' type='text/javascript'>
    <!--
    if (!document.phpAds_used) document.phpAds_used = ',';
    phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

    document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
    document.write ("http://warning9.com/ads/adjs.php n=" + phpAds_random);
    document.write ("&amp;what=zone:21");
    document.write ("&amp;exclude=" + document.phpAds_used);
    if (document.referrer)
    document.write ("&amp;referer=" + escape(document.referrer));
    document.write ("'><" + "/script>");
    //-->
    </script><noscript><a href='http://warning9.com/ads/adclick.php n=abe1b1f1' target='_blank'><img src='http://warning9.com/ads/adview.php what=zone:21&amp;n=abe1b1f1' border='0' alt=''></a></noscript>
    </span>
    </td>
    </tr>
    </table>
    </body>
    </html>

    It's probably something obvious that I missed.


  • Jimmy.Lin

    Could you post the relevant section of your code

    I have used the same code successfully here: http://somnaticdev.spaces.live.com/ (see Step 5 for Javascript Code) and it works. Maybe you can compare this to yours :)


  • AshiTenshi

    I added that code, and It's still not refreshing. Anymore Ideas


  • sureshvb

    I'd also be very wary of your "window.setInterval(updateData, 5);"
    That means you are calling updateData every 5 milliseconds, i.e. 200 times PER SECOND!

    I'm guessing you want to call it every 5 seconds Use
    window.setInterval(updateData, 5000);

  • HumbleServant

    window.setInterval(methodToCall, durationinMs);

    so if you want to call a method named updateData every 60 secs you would write:

    <html>
    <head>
    <script language="javascript" type="javascript">
    window.setInterval(updateData, 60000);
    function updataData() {
    // Assign some values to elements
    myText.innerHTML = "New Text";
    }
    </script>
    </head>
    <body onload="updateData">
    <span id="myText">Text</span>
    </body>
    </html>

    Do not reload the whole page, but update elements instead


  • Geoff Dupuis

    I've seen folks have problems using document.write inside a gadget; I attribute it to the following warning:

    "You should not use the write or writeln methods on the current document after the document has finished loading unless you first call the open method, which clears the current document's window and erases all variables."

    (copied from http://msdn.microsoft.com/library/default.asp url=/workshop/author/dhtml/reference/methods/write.asp)

    Perhaps instead you could append your text using:

    document.body.innerHTML += myHtmlString;

    Alternatively, you could use document.createElement, set its attributes, and add it using document.body.appendChild.


  • Need Help Refreshing My Gadget.