Firefox 中的 event.offsetX [英] event.offsetX in Firefox
本文介绍了Firefox 中的 event.offsetX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><头><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>在此处插入标题</title><脚本语言="javascript">函数主(){var canvas = document.getElementById("canvas");canvas.addEventListener("mousemove", function(e){if (!e) e = window.event;var ctx = canvas.getContext("2d");var x = e.offsetX;var y = e.offsetY;ctx.fillRect(x, y, 1, 1);});}头部><body onload="main();"><div style="width: 800px; height: 600px; -webkit-transform: scale(0.75,0.75); -moz-transform: scale(0.75,0.75)"><canvas id="canvas" width="400px" height="400px" style="background-color: #cccccc;"></canvas>