ie 處理 gif動畫 的onload 事件的一個 bug
更新時間:2007年04月12日 00:00:00 作者:
如果 <img>標簽的 src為一個 gif 動畫,那么他的 onload事件會重復觸發(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動畫,這個會重復彈出")
}
</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設置為 靜態(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動畫,這個會重復彈出")
}
</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設置為 靜態(tài) gif 或者 jpg ,bmp等其他格式,也不會出現(xiàn)這個bug
相關文章
JavaScript動態(tài)添加style節(jié)點的方法
這篇文章主要介紹了JavaScript動態(tài)添加style節(jié)點的方法,涉及javascript節(jié)點操作的相關技巧,需要的朋友可以參考下2015-06-06

