I'm going mad with the following problem which does not happen on any other browser (Chrome, Firefox):
Here's my javascript code:
<script type="text/javascript">
var ctr = 0;
function getImage(url)
{
var img = document.createElement("img");
img.src = url + "&nc=" + ctr;
ctr ++;
img.width = 128;
img.height = 128;
document.body.appendChild(img);
}
for (var i = 0; i < 10; i=i+1)
{
//THIS FAILS MOST OF THE TIME
setTimeout("getImage('http://myHostName:9980/GenerateImageStatic?parameter=1')", 1000);
//THIS WORKS! WHY?
//setTimeout("getImage('http://maps.google.com:80/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false')", 1000);
}
</script>
For HTTP Server I'm using BOOST sample ASIO HTTP Server Link I modified it so for any URI request, it sends a png file (I've tried various files to make sure it's not PNG encoding that's bad). The HTTP header has Content-type: "image/png". So correct mime type is sent.
I've been trying to find a solution for a long time. Read through various posts:
Any ideas? Thanks.
EDIT I added myHostName to trusted sites. I also lowered the security settings to low for internal and internet sites. I'm going to try to disable keepalive on the server if enabled. However as I mentioned I don't see IE making an attempt to fetch the image at all. The socket doesn't receive any requests from IE, so removing keep-alive from headers may not help.
Possible causes. The web page is not pointing to the correct URL (location) of the image. The server or computer hosting the image has moved or removed the image, and the web page has not yet been updated. The web page or computer hosting the image is getting too many requests and can't send you the image.
You need to either retype your HTML code in upper case: <IMG SRC="MY_IMAGE. GIF"> or you need to rename the file on the server to lower case to coordinate with the HTML page. It is possible that your image files were uploaded correctly to the server, but the server's path to the image is incorrect.
Check what color mode your images are in.
I have accidentally switched the color mode of an image from RGB8 to CMYK in Photoshop, and ran into the same problem. IE8 would fail to display the image, while Firefox would have no trouble at all.
I believe that in IE you need to set the source after the element is appended to the DOM, otherwise it won't render correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With