I'm trying to show either an image or static map image depends on existence of the image.
I want to pass my image path to java script function since the path is dynamic in my program. So, if the image does not exist in given path, show the static google map image.
I am using that code to do that, but seems to be not working. Can you help me?
function initialize() {
var img = document.getElementById("super");
var mdata = $('#image_div');
var mpath = mdata .data('path');
img.src =mpath ;
img.onerror = function( ) {
document.getElementById("super").style.display = "block";
alert("failed to load");
}
img.onload = function( ) {
alert("do nothing");
};
}
Here is the fiddle: http://jsfiddle.net/H2gwu/2/ http://jsfiddle.net/H2gwu/3/