var flag=false; function drawimage(imgd){ /*var link1 = document.createelement("a"); link1.href = imgd.src; link1.target = "_blank"; imgd.parentnode.insertbefore(link1,imgd); link1.appendchild(imgd);*/ var image=new image(); image.src=imgd.src; if(image.width>0 && image.height>0){ flag=true; if(image.width>900){ imgd.width=900; imgd.height=math.round(900/(image.width/image.height)); } else{ imgd.width=image.width; imgd.height=image.height; } } }