As a provider of a service that helps users find the location of pictures, I face a challenge due to the fact that the pictures are stored on another internal site. Some users may not have access to this site as my service offers additional information. The traditional method of adding alt attributes to images does not give me enough flexibility to inform users of how they can view the pictures.
<div id=theDiv>
<img src='http\internalSite\' + this.name + '.jpg'
alt='Please connect to internalSite to see the picture ' + this.name + '.jpg'>
</div>
I am looking to enhance the alt text by providing a direct link to the 'internalSite' or possibly loading the connection page in an iFrame for a better user experience. However, I have found it challenging to achieve this functionality using the onError attribute of the IMG tag when the image is dynamically added to the page by script.
Is there a way for my script to detect if the picture is unavailable beforehand so that I can make a decision on what action to take?
In pseudo code:
if (isURLavailble(path)){
loadPicture();
} else {
loadSomethingNiceToSayPicIsntAvailable();
}
Is there a reliable cross-browser function that can be defined to check if a URL is available like isURLavailable(path)?