使用onerror 屬性處理損壞的圖像
HTML 元素提供了一個onerror 屬性,允許開發人員指定替代圖像或在主圖像載入失敗時要採取的操作。但是,使用者會報告在 Chrome 和 Mozilla 等某些瀏覽器中遇到此屬性的問題。
要解決此問題,建議使用以下程式碼結構:
<code class="html"><img src="/static/imghwm/default1.png" data-src="invalid_link" class="lazy" onerror="this.onerror=null;this.;" alt="為什麼圖像的「onerror」屬性在 Chrome 和 Mozilla 中有時會失敗?" ></code>
此程式碼透過在第一次觸發後將 onerror 處理程序設為 null 來運作。這可以防止備份 URL 無效時出現無限循環的錯誤事件。
現場示範:http://jsfiddle.net/oLqfxjoz/
以上是為什麼圖像的「onerror」屬性在 Chrome 和 Mozilla 中有時會失敗?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatoryand and powerincreatingsmoothcsssanimations.keytricksinclude:1)definingsmoothtransitionsbetnestates,2)使用AnimatingMultatingMultationMultationProperPertiessimultane,3)使用使用4)使用BombingeNtibalibility,4)使用CombanningWiThjavoFofofofoftofofo

CSSCOUNTERSAREDOMANAGEAUTOMANAMBERINGINWEBDESIGNS.1)他們可以使用forterablesofcontents,ListItems,and customnumbering.2)AdvancedsincludenestednumberingSystems.3)挑戰挑戰InclassINCludeBrowsEccerCerceribaliblesibility andperformiballibility andperformissises.4)創造性

使用滾動陰影,尤其是對於移動設備,是克里斯以前涵蓋的一個微妙的UX。傑夫(Geoff)涵蓋了一種使用動畫限制屬性的新方法。這是另一種方式。

文章討論了CSS FlexBox,這是一種佈局方法,用於有效地對齊和分佈響應設計中的空間。它說明了FlexBox用法,將其與CSS網格進行了比較,並詳細瀏覽了瀏覽器支持。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

SublimeText3 Linux新版
SublimeText3 Linux最新版

Dreamweaver CS6
視覺化網頁開發工具