window.onload =function(){
var body =document.getElementsByTagName('body')[0];
var img =new? Image ();
img.onload=function(){
}
img.onerror=function(){
console.log('請求失敗');
}
img.onabort=function(){
console.log('朕放棄了');
}
img.src="http://n.sinaimg.cn/fashion/transform/20160706/A0_d-fxtsatm1496997.jpg"
body.appendChild(img);
}
img屬性:
1.complete? 返回瀏覽器是否已完成對圖像的加載。
2.hspace? ? 設置或返回圖像左側和右側的空白。
3.vspace? ? ? 設置或返回圖像的頂部和底部的空白。
事件句柄
1.onabort? ? 當用戶放棄圖像的加載時調用的事件句柄。
2.onerror? ? ? ? 在加載圖像的過程中發生錯誤時調用的事件句柄。
3.onload? ? ? ? 當圖像加載完畢時調用的事件句柄。