<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>导航</title>
<style type="text/css">
<script>
function drawOnCanvas ()
{
var x = 1;
var img = new Image;
var callback = function ()
{
img.src = "pic.jpg";
x = 2;
return x;
}
img.onload = callback;
img.onload ();
console.log (x);
document.body.appendChild (img);
}
window.onload = drawOnCanvas;
</script>
</head>
<body>
</body>
</html>
追问十分感谢回答,可是还是取不到里面的值,只要原因是由于得不到e.target呀