Hallo,
var RessourceTester = function(timeout)
{
this.timeout = timeout;
this.url = function(url, cb)
{
var timeout;
var im = document.createElement('object');
im.style.height = im.style.width = '1px';
im.onload = function(e)
{
try
{
im.parentNode.removeChild(im);
} catch(e) { ; };
window.clearTimeout(timeout);
cb(url, true);
};
im.data = url;
if (this.timeout)
{
timeout = window.setTimeout(function()
{
try
{
im.parentNode.removeChild(im);
} catch(e) { ; };
cb(url, false);
}, this.timeout * 1000);
};
document.body.appendChild(im);
};
};
var cb = function(url, available)
{
(window.console.warn || alert)(url + ' is ' + available);
};
var testor = new RessourceTester(10);
testor.url('http://www.google.de/', cb);
testor.url('http://example.com', cb);
testor.url('http://www.google.de/asdf', cb);
testor.url('http://www.example.lol', cb);
firefox, opera und der battarie machens alle brav.
Tschö