Home
Web Front-end
JS Tutorial
Solution to the problem that the onload event will be executed only after the img element is created but not added to the document_javascript tips



Solution to the problem that the onload event will be executed only after the img element is created but not added to the document_javascript tips
img
Example
Copy code The code is as follows:
< HTML>
<script> <br>var img = document.createElement('img'); <br>img.src = "http:// /www.sinaimg.cn/rny/sinamail57/skins/110318/17/logo.jpg"; <br>img.onload = function(){alert(this.width);}; <br></script>