ie 處理 gif動畫 的onload 事件的一個 bug
更新時間:2007年04月12日 00:00:00 作者:
如果 <img>標(biāo)簽的 src為一個 gif 動畫,那么他的 onload事件會重復(fù)觸發(fā)。
firefox就沒有這樣的問題。
<img src="http://zi.csdn.net/intel_120x60.gif" onload='gorush(this)'>
<script type="text/javascript">
//by Go_Rush(阿舜) from http://ashun.cnblogs.com/
function gorush(obj){
alert("如果img的src為多幀gif動畫,這個會重復(fù)彈出")
}
</script>
解決辦法:
<img src="http://zi.csdn.net/intel_120x60.gif" onload='gorush(this)'>
<script type="text/javascript">
//by Go_Rush(阿舜) from http://ashun.cnblogs.com/
function gorush(obj){
alert("這樣,就只會彈出一次")
obj.onload=null;
}
</script>
如果 src設(shè)置為 靜態(tài) gif 或者 jpg ,bmp等其他格式,也不會出現(xiàn)這個bug
firefox就沒有這樣的問題。
<img src="http://zi.csdn.net/intel_120x60.gif" onload='gorush(this)'>
<script type="text/javascript">
//by Go_Rush(阿舜) from http://ashun.cnblogs.com/
function gorush(obj){
alert("如果img的src為多幀gif動畫,這個會重復(fù)彈出")
}
</script>
解決辦法:
<img src="http://zi.csdn.net/intel_120x60.gif" onload='gorush(this)'>
<script type="text/javascript">
//by Go_Rush(阿舜) from http://ashun.cnblogs.com/
function gorush(obj){
alert("這樣,就只會彈出一次")
obj.onload=null;
}
</script>
如果 src設(shè)置為 靜態(tài) gif 或者 jpg ,bmp等其他格式,也不會出現(xiàn)這個bug
相關(guān)文章
JavaScript動態(tài)添加style節(jié)點(diǎn)的方法
這篇文章主要介紹了JavaScript動態(tài)添加style節(jié)點(diǎn)的方法,涉及javascript節(jié)點(diǎn)操作的相關(guān)技巧,需要的朋友可以參考下2015-06-06javascript Promise簡單學(xué)習(xí)使用方法小結(jié)
下面小編就為大家?guī)硪黄猨avascript Promise簡單學(xué)習(xí)使用方法小結(jié)。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05JS從非數(shù)組對象轉(zhuǎn)數(shù)組的方法小結(jié)
這篇文章主要給大家介紹了關(guān)于JS從非數(shù)組對象轉(zhuǎn)數(shù)組的一些方法,分別是Array.prototype.slice.call(obj)、Array.from(obj)、[…obj]和Object.values(obj)等方法的詳細(xì)實(shí)現(xiàn)方法,需要的朋友可以參考下。2018-03-03