96turnerri
11-19-2003, 09:33 PM
hi i found this script to display a server status, i wish to edit it so it can be used for any domain name not just one with picture specified heres the orginal code
<script type="text/javascript">
var url = "http://www.yourprivateserver.com/foo.gif";
var img = new Image();
img.src = url;
img.onload = function()
{
// If the server is up, do this.
alert("Server is up!");
}
img.onerror = function()
{
// If the server is down, do that.
alert("Server is down!");
}
</script>
and hers my code
<script type="text/javascript">
var url = "http://www.yourdomain.com/index.htm";
var page = new Image();
page.src = url;
page.onload = function()
{
// If the server is up, do this.
alert("Server is up!");
}
page.onerror = function()
{
// If the server is down, do that.
alert("Server is down!");
}
</script>
if someone could take a look at it and see what im doing wrong that would be great, all i get is server is down, even tho i know the page exists
Thanks
96
<script type="text/javascript">
var url = "http://www.yourprivateserver.com/foo.gif";
var img = new Image();
img.src = url;
img.onload = function()
{
// If the server is up, do this.
alert("Server is up!");
}
img.onerror = function()
{
// If the server is down, do that.
alert("Server is down!");
}
</script>
and hers my code
<script type="text/javascript">
var url = "http://www.yourdomain.com/index.htm";
var page = new Image();
page.src = url;
page.onload = function()
{
// If the server is up, do this.
alert("Server is up!");
}
page.onerror = function()
{
// If the server is down, do that.
alert("Server is down!");
}
</script>
if someone could take a look at it and see what im doing wrong that would be great, all i get is server is down, even tho i know the page exists
Thanks
96