Sorry for replying my own post, but this calls for more information.
Laurent Bugnion wrote:
Hi,
Hansen wrote:
>Hi!
Is it possible to perform a webrequest within javascript to find out
if a given url is reachable? (If it isn't then show a placeholder image).
The url can point to both images, video or regular websites.
best regards
Hansen
http://www.galasoft-lb.ch/myjavascript/IsURlActive/
Code:
http://www.galasoft-lb.ch/myjavascri.../check-url.txt
HTH,
Laurent
Note: This will work only within the "cross-domain" policy. You cannot
(with the normal permissions) send such a request to another domain.
However, images can send requests to another domain, so this code might
not be sufficient.
Another way would be to use the onerror event handler of the Image object:
<img src="myImage.gif" id="myImage" onerror="showDefaultImage();" />
with
function showDefaultImage()
{
var nImage = document.getElementById( "myImage" );
if ( nImage
&& nImage.src )
{
nImage.src = "iAmSureThatThisImageExists.gif";
}
}
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering:
http://www.galasoft-LB.ch
Private/Malaysia:
http://mypage.bluewin.ch/lbugnion
Support children in Calcutta:
http://www.calcutta-espoir.ch