locked
Refreshing Sidebar Gadget RRS feed

  • Question

  • Does anyone know of any code in Javasrcipt that can refresh the docked form of a gadget, without closing and opening it again?
    Thursday, July 19, 2007 8:42 PM

All replies

  • You could try window.reload(); or window.location.href = window.location.href;

    Andy
    Thursday, July 19, 2007 8:57 PM
  • What type of element do you want to refresh?  I presume it images.  Text and HTML type elements (DIV/SPAN/P etc) should all update automatically as soon as they're changed. 

    IMG's need to be modified to update.  You can do something along the lines of the code below to refresh them, it's a bit crude though:

    Code Snippet

    function refreshPage() {
       var myIMG = document.getElementsByTagName("img");
       var tmp;
       for (var i = 0; i < myIMG.length; i++) {
         tmp = myIMG[i].src;
         myIMG[i].src = "";
         myIMG[i].src = tmp;
       }
     }



    If you need to rerun an event on the elements, such as onload.  Use the following method:

    Code Snippet

    function refreshPage() {
       var myIMG = document.getElementsByTagName("img");
       var tmp;
       for (var i = 0; i < myIMG.length; i++) {
         myIMG[i].fireEvent("onload");
       }
     }



    Friday, July 20, 2007 7:39 AM
  • I use setInterval for mine...

    Code Snippet

    var refreshTasks = window.setInterval("myFunction()", 300000);


    Just replace myFunction() with the name of a javascript function.
    Thursday, August 2, 2007 1:56 PM