!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body{
margin: 0;
padding: 0;
}
</style>
<script type="text/javascript" >
window.onload=function(){
var canvas=document.getElementById('canvas');
var context=canvas.getContext('2d');
context.fillStyle='green';
context.fillRect(0,0,400,300);
window.location=canvas.toDataURL('image/jpeg');
}
</script>
</head>
<body>
<canvas id="canvas" width="400" height="300"></canvas>
</body>
</html>
用火狐打开就是直接一张图像,但是谷歌就报错。
这是哪里出了错呢。
用location替换window.location