1<! DOCTYPE html>234<title>insert you title</title>5<meta name= ' description ' content= ' This is my page ' >6<meta name= ' keywords ' content= ' keyword1,keyword2,keyword3 ' >7<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<link rel= ' stylesheet ' type= ' text/css ' href= './css/index.css '/>9<script type= ' text/javascript ' src= './js/jquery-1.12.1.min.js ' ></script>Ten<style type= ' text/css ' > One Html,body { Amargin:0; padding:0; - } - the HTML { -height:100%; - } - + Body { -Background: #000; + } A at #can { -Display:block; margin:25px auto;border-radius:2px;background: #FFF; - } -</style> -<script type= ' Text/javascript ' > -$(function(){ in varcan = $ (' #can '). Get (0); - varOcan = Can.getcontext (' 2d '); to varoimg = $ (' #img '). Get (0); + /* - How the picture is preloaded: the The system automatically creates a new image () object when the United States uses a tag in the HTML Image DOM, which contains many properties and times where properties and events can be pre-loaded for our pictures * include: $ Properties:Panax Notoginseng Complete - Readystate:complete Loading the onerror: + onload A */ the if(Oimg.complete = = ' true ' | | oimg.readystate = = ' complete ' | | oimg.readystate = = ' Loading '){ + drawImage (); -}Else{ $Oimg.onload =DrawImage; $ } - functionDrawImage () { - /* the JavaScript Demo code ... - */Wuyi } the } ); -</script> Wu -<body> About<canvas id= ' can ' width= ' height= ' > detects that your browser version is too low, please upgrade your browser version for a better user experience ...</canvas> $ -</body> -
[JavaScript HTML Dom Image object event load mode] Object event load mode