L
long5120
I am trying to use webpage with javascript to check if a web server is
responding. I was thinking of using 2 frames. Frame1 will have the
site, and the Frame2 will be a status bar (not really needed). This
webpage will call the site's homepage and refresh in 10 seconds. If I
can see the homepage then, the site is up, else site is down. I have
an example of my code below.
My question, is it possible to check the homepage in frame1 (after
refreshed) and see if the page comes up. What I would be looking for
is HTTP Errors or "Cannot find server or DNS Error" pages. I was
thinking of reading the page title and compare it with the original,
but I cannot seem to reference the document title within frame1. Or
parse thru the document text in frame1 and look for keywords like
"Cannot find server...". Also another posssibility could be to check
the HTTP header. I have search thru many newsgroups and websites, but
still haven't got a final solution.
Any help would be greatly appreciated.
Thanks...
******************************************************************
Sample Code
******************************************************************
<html>
<SCRIPT LANGUAGE="JavaScript">
site="http://www.timeanddate.com/counters/newyear.html";
delay=10000;
</SCRIPT>
<frameset rows="*,25" border=0 frameborder=1 framespacing=0
onLoad="window.frames[0].location=site;window.setInterval('window.frames[0].location=site',delay)">
<frame name="TopFrame" scrolling=no>
<frame name="BottomFrame" scrolling=no>
</frameset>
</html>
******************************************************************
Variation of Sample Code
******************************************************************
<html>
<script language=javascript>
site="http://www.timeanddate.com/counters/newyear.html";
delay=10000;
function refresh()
{
window.frames[0].location=site;
//code to check if site is up
}
</script>
<frameset rows="*,25" frameborder=1
onLoad="window.setInterval('refresh()',delay)">
<frame name="TopFrame" scrolling=no>
<frame name="BottomFrame" scrolling=no>
</frameset>
</html>
responding. I was thinking of using 2 frames. Frame1 will have the
site, and the Frame2 will be a status bar (not really needed). This
webpage will call the site's homepage and refresh in 10 seconds. If I
can see the homepage then, the site is up, else site is down. I have
an example of my code below.
My question, is it possible to check the homepage in frame1 (after
refreshed) and see if the page comes up. What I would be looking for
is HTTP Errors or "Cannot find server or DNS Error" pages. I was
thinking of reading the page title and compare it with the original,
but I cannot seem to reference the document title within frame1. Or
parse thru the document text in frame1 and look for keywords like
"Cannot find server...". Also another posssibility could be to check
the HTTP header. I have search thru many newsgroups and websites, but
still haven't got a final solution.
Any help would be greatly appreciated.
Thanks...
******************************************************************
Sample Code
******************************************************************
<html>
<SCRIPT LANGUAGE="JavaScript">
site="http://www.timeanddate.com/counters/newyear.html";
delay=10000;
</SCRIPT>
<frameset rows="*,25" border=0 frameborder=1 framespacing=0
onLoad="window.frames[0].location=site;window.setInterval('window.frames[0].location=site',delay)">
<frame name="TopFrame" scrolling=no>
<frame name="BottomFrame" scrolling=no>
</frameset>
</html>
******************************************************************
Variation of Sample Code
******************************************************************
<html>
<script language=javascript>
site="http://www.timeanddate.com/counters/newyear.html";
delay=10000;
function refresh()
{
window.frames[0].location=site;
//code to check if site is up
}
</script>
<frameset rows="*,25" frameborder=1
onLoad="window.setInterval('refresh()',delay)">
<frame name="TopFrame" scrolling=no>
<frame name="BottomFrame" scrolling=no>
</frameset>
</html>