我需要調用函數calllogin當img標籤被加載後,該函數應該每10000ms連續運行。它提醒調用,但它不調用函數callogin調用setInterval函數onload事件的圖片標籤拋出錯誤:undefined函數
<script>
function calllogin(id){
console.log('calling calllogin function',id);
}
</script>
<img src="upload/thumb/image.jpg" alt="Ad Thumb" onload="alert('calling');setInterval(function(){calllogin(114)},10000);"/>
它引發以下錯誤
Uncaught ReferenceError: calllogin is not defined(…)
感謝
嘗試'onclick'。 – Mahi
對我來說工作很好。我的控制檯中有114個。我認爲問題是與img src。 –
@AmitJamwal是啊可能圖像未加載,所以函數將不會調用 – Mahi