function click_canvas(e){
//var scrollTop, scrollLeft;
//if (document.documentElement && document.documentElement.scrollTop) { // scrollTop = document.documentElement.scrollTop; // scrollLeft = document.documentElement.scrollLeft; //} else if (document.body) { // scrollTop = document.body.scrollTop; // scrollLeft = document.body.scrollLeft; //}
var imgX = e.clientX + $(document.body).width()//scrollLeft var imgY = e.clientY + $(document.body).height()-60//scrollTop - 60//这个60估计是地址栏的高度
//在canvas上定位 pin(img, imgX, imgY)
//计算相对位置 var x = imgX - $('#canvas').offset().left var y = imgY - $('#canvas').offset().top
//计算比率
var sx = Math.min(Math.max((x / canvas.width),0), 1)
var sy = Math.min(Math.max((y / canvas.height),0), 1)
}
考虑用e.offsetX,e.offsetY 来简化操作.