为什么运行错误
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>html5 localStorage实现图片存储</title>
<script>
var src='images/key.png';
function set(key){
var img=document.createElement('img');
img.addEventListener('load',function(){
var imgCanvas=document.creatElement('canvas');
imgContext=imgCanvas.getContext('2d');
//确保canvas元素的大小和图片尺寸一致
imgCanvas.width=this.width;
imgCanvas.height=this.height;
//渲染图片到canvas中
imgContext.drawImage(this,0,0,this.widht,this.height);
//用data url的形式取出
var imgAsDataURL=imgCanvas.toDataURL('images/png');
//保存到本地存储中
try{
localStorage.setItem(key,imgAsDataURL);
}
catch(e){
console.log('Storage failed:'+e)
}
},false);
img.src=src
}
function get(key){
var srcStr=localStorage.getItem(key);
var imgobj=document.createElement('img');
imgobj.src=srcStr;
document.body.appendChild(imgobj);
}
</script>
</head>
<body>
</body>
</html>