0
이 작은 그림 응용 프로그램 유형의 작업을하고 있지만 Firefox에서는 작동하지 않습니다. 그것은 크롬에서 잘 작동합니다. 여기 자바 스크립트가 있습니다. 그런 다음 HTML에 일반 캔버스 요소가 있습니다. 어떤 도움을 주셔서 감사합니다!캔버스 그리기 응용 프로그램이 파이어 폭스에서 작동하지 않을 경우
/* FOR THE DRAWING APPLICATION */
/* =========================== */
var canvasMouse, contextMouse;
var started = false;
var x, y;
function initMouse() {
// Get the drawing canvas
canvasMouse = document.getElementById('drawing');
contextMouse = canvasMouse.getContext('2d');
// Add some event listeners so we can figure out what's happening
// and run a few functions when they are executed.
canvasMouse.addEventListener('mousemove', mousemovement, false);
canvasMouse.addEventListener('mousedown', mouseclick, false);
canvasMouse.addEventListener('mouseup', mouseunclick, false);
}
function mouseclick() {
// When the mouse is clicked. Change started to true and move
// the initial position to the position of the mouse
contextMouse.beginPath();
contextMouse.moveTo(x, y);
started = true;
}
function mousemovement(e) {
// Get moust position
x = e.offsetX;
y = e.offsetY;
// If started is true, then draw a line
if(started) {
contextMouse.lineTo(x, y);
contextMouse.stroke();
}
}
function mouseunclick() {
// Change started to false when the user unclicks the mouse
if(started) {
started = false;
}
}
아이디어가 있으십니까?
캔버스 요소는 다른 브라우저에서 올바르게 작동하려면 다소 새롭고 까다로운 요소입니다. 정확히 작동하지 않는 것은 무엇입니까? – kevin628
잘 작동하지 않습니다. 그림이 작동하지 않습니다. 일종의 간단한 드로잉 응용 프로그램이라고 생각하지만 그릴 수는 없습니다! – Johnny