I need to be able to display a web site in a sidebar gadget, and have it update every 10 seconds. It is used to monitor servers. The gadget needs to be about 500 x 600 pixels.
I have seen some messages talking about using iframes to display a web site in a sidebar gadget, but I cannot find a way to successfully get it to refresh at a specified interval (say every 10 seconds).
Any assistance and/or code samples would be greatly appreciated.
Thanks!

Web Site in sidebar Gadget; Need to Refresh Every 10 Seconds
RFDID
Having a similar problem using AJAX, here's how I solved it...
var http = getHTTPObject();
function getHTTPObject() {
var req;
if(window.XMLHttpRequest) {
try { req = new XMLHttpRequest(); } catch(e) { req = false; }
} else if(window.ActiveXObject) {
try { req = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {
try { req = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { req = false; }
}
}
return req;
}
http.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
Sorry if the posting is "sloppy"... this is my very first post here.. :p The last line of code is the "trick" here... just be sure it is set to a date in the past...
LadyReader
smudie
JV Chevy
I've tried to use this method to refresh the gadget but all of the content disappears and comes back a moment later and none of my links will work.
Here is the whole script for the main gadget (It's an RSS gadget which I would like to update every 10 minutes), any help would be fantastic :
<html>
<head>
<title>The Vista Forums Post Gadget</title>
<link href="css/gadget_layout.css" rel="stylesheet" type="text/css" />
<script LANGUAGE="JScript" >
var theme ="TheVistaForums";
var oXml = new XMLHttpRequest(); //ActiveXObject("Microsoft.XMLHTTP") //
var responseData;
var rssCount =0;
var rssPage =0;
var rsstimeout=3600;
window.setInterval(refreshGadget, 10000);
function refreshGadget() {
location.href = location.href;
}
window.onload = function(){
LoadThemeSettings();
gRSS.innerHTML = "<img src=themes/"+theme+"/16-on-black.gif> Reading Posts...";
System.Gadget.settingsUI = "Theme.html";
System.Gadget.onSettingsClosed = SettingsClosed;
PaintScreen();
var oLoad = setTimeout(oLoado, 500);
}
function oLoado(){
if (oXml ==null)
oXml = new XMLHttpRequest();
oXml.open( "GET", "http://thevistaforums.com/index.php act=rssout&id=3", true );
oXml.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
oXml.send();
}
oXml.onreadystatechange = function(){
if (oXml.readyState == 4)
if (oXml.status == 200){
var rXML = oXml.responseXML;
responseData = rXML;
gRSS.innerHTML ="";
rssPage = 0;
buildPage(0);
oXml = null;
var o = setTimeout(oLoado, rsstimeout);
}
}
function SettingsClosed() {
LoadThemeSettings();
PaintScreen();
}
function LoadThemeSettings(){
//Theme Code
//-----------------------------------------------------------------------
var gThemeSetting = System.Gadget.Settings.read("gThemeSetting");
if (gThemeSetting != "")
theme = gThemeSetting ;
//background
background.src = "Themes/"+ theme +"/Docked.png";
//-----------------------------------------------------------------------
}
function PaintScreen(){
System.Gadget.beginTransition();
var NewPostsImage = background.addImageObject("Themes/"+ theme +"/NewPosts.png", 14, 167);
var UsersOnlineImage = background.addImageObject("Themes/"+ theme +"/wiki.png", 14, 184);
var ControlPanelImage = background.addImageObject("Themes/"+ theme +"/ControlPanel.png", 14, 200);
var gnavBackImage = background.addImageObject("Themes/"+ theme +"/gnavBack.png", 40, 145);
var buttonUp_OffImage = background.addImageObject("Themes/"+ theme +"/buttonUp_Off.png", 45, 147);
var buttonDown_OffImage = background.addImageObject("Themes/"+ theme +"/buttonDown_Off.png", 67, 146);
}
function OpenURL(url){
System.Shell.execute(url);
}
function NewPostsClick(){
System.Shell.execute("http://thevistaforums.com/index.php act=Search&CODE=getnew");
}
function WikiClick(){
System.Shell.execute("http://thevistaforums.com/index.php autocom=ineo");
}
function ControlPanelClick(){
System.Shell.execute("http://thevistaforums.com/index.php act=UserCP&CODE=00");
}
function buttonUpClick(){
rssPage-=3;
if(rssPage <= 0)
rssPage=0;
buildPage(rssPage);
}
function buttonDownClick(){
rssPage+=3;
if(rssPage > rssCount-3)
rssPage = rssCount-3;
buildPage(rssPage);
}
function buildPage(pageNo)
{
var rXML = responseData;
gRSS.innerHTML ="";
var nl = rXML.getElementsByTagName('item');
for( var i = 0; i < nl.length; i++ ) {
if(i >=pageNo){
var nli = nl.item(i);
var title = new String(nli.getElementsByTagName('title')[0].text);
var link = nli.getElementsByTagName('link')[0].text;
var pubDate = nli.getElementsByTagName('pubDate')[0].text;
var d = new Date(pubDate);
if(title.length > 17)
title = title.substring(0,17) +"...";
var onC ="OpenURL('"+link+"')";
var RSSRow = "<div onclick=\""+onC+"\" class=\"RSSRow\"><div class=\"RSSHeader\">"+title+"<div class=\"RSSDate\">"+d.toLocaleDateString()+"</div></div></div>"
rssCount = nl.length;
if(i== pageNo+3)
i=nl.length;
gRSS.innerHTML += RSSRow;
}
}
}
</script>
</head>
<body>
<div>
<g:background id="background" style="position:absolute; z-index:-999" />
<div id="gHeaderText" style="position:absolute; left:19; top:8"></div>
<div id="gRSSFeed" style="position:absolute;">
<div id="gRSS"></div>
<div>
<div onclick="NewPostsClick();" id="gNewPostsText" style="position:absolute;">Latest Posts</div>
<div onclick="WikiClick();" id="gWikiText" style="position:absolute;">WiKi</div>
<div onclick="ControlPanelClick();" id="gControlPanelText" style="position:absolute;">Control Panel</div>
<div onclick="buttonUpClick();" id="gbuttonUp" style="position:absolute;"></div>
<div onclick="buttonDownClick();" id="gbuttonDown" style="position:absolute;"></div>
</div>
</body>
</html>
As you may see most of the work is done in this section
_________________________________________________________________________
window.onload = function(){
LoadThemeSettings();
gRSS.innerHTML = "<img src=themes/"+theme+"/16-on-black.gif> Reading Posts...";
System.Gadget.settingsUI = "Theme.html";
System.Gadget.onSettingsClosed = SettingsClosed;
PaintScreen();
var oLoad = setTimeout(oLoado, 500);
}__________________________________________________________________________
The problem is this section is only performing once as are the links in the body section, once the refresh happens all the links die.
Also I'd like to be able to change stylesheet based on the theme (I have 8 so far), obviously if I change the 'var theme ="TheVistaForums";' to be in front of the stylesheet definition I should then be able to use the "theme" variable to define the stylesheet location, but how
Thanks for any help
Dan F. Jansson
XMLHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
Change "XMLHttp" to whatever your using
mstcrow5429
window.setInterval(refreshGadget, 10000);
...
function refreshGadget() {
location.href = location.href;
}
ro88o
HKEC
url + " zzz='' + Math.random();
rogupta
abhishek_6023
eg.
<HEAD>
<SCRIPT language="javascript" type="text/javascript">
...
</SCRIPT>
</HEAD>