Reputation:
i have very serious problem if any tech expert can help...thank you in advance..
i have below html file on which i dont have any control
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<a href="http://cafebar.ro/home.php" target=_blank><img class="photo" width="100%" src="http://cityadvertisement.com/Photo-Gadgets/Sportsgirls/photo-102.jpg"></a>
</body>
</html>
now what i want to do is if the above image does't found then it should display default image (i can not update above html file). but on server i can create e404.html page which will be displayed if image is not exist on server but when i run above html page it doesnt display anything... and On my yahoo hosting i dont have .htaccess
can anybody tell me how i can display default image on above html page.
Upvotes: 0
Views: 1821
Reputation: 446
Not sure if this will be a optimal solution... create a new page with iframe of the html page that you have. Have script to check if the image is available, else change the image src at runtime.
Upvotes: 0
Reputation: 201598
If you cannot change the HTML document, then you are out luck unless you can affect the server referred to in the src
attribute, i.e. cityadvertisement.com. It is the response of that server that matters, not some error response of some other server to some other request.
If you have access to that server, you should make it return some default image in response to the request for http://cityadvertisement.com/Photo-Gadgets/Sportsgirls/photo-102.jpg when a real image does not exist. Returning an HTML (error) document does not help, because the browsers expect an image and will discard an HTML document response when processing an img
tag.
I don’t quite understand why you say that you can “create e404.html page” but can’t use .htaccess. Does this mean that the server has fixed .htaccess that sets e404.html as error document for 404 errors? Then you’re stuck, I’m afraid.
Upvotes: 0