我在Mozilla的getImageData有問題。我做了一個函數,點擊畫布後獲取鼠標的座標。座標是好的,但是有一個問題,在Mozilla中,它給出了很多糟糕的getImageDatas數字 - 例如在chrome中,它給出了紅色:10,綠色:0,藍色:10,Mozilla給出紅色:60,綠色:255,藍色:10 ...我不知道問題出在哪裏......請你幫忙嗎? 下面是函數:http://pastebin.com/MjnG0NbmMozilla的getImageDataProblem
0
A
回答
0
也許你getMousePos()並不總是得到希望的結果
The amount of scrolling that has been done of the viewport area (or any other
scrollable element) is taken into account when computing the bounding rectangle.
This means that the top and left property change their values as soon as the
scrolling position changes (so their values are relative to the viewport and not
absolute). If this is not the desired behaviour just add the current scrolling
position to the top and left property (via window.scrollX and window.scrollY) to
get constant values independent from the current scrolling position.
試試這個:
function getMousePosition(canvas, evt) {
return {
x: evt.clientX - canvas.offsetLeft + window.scrollX,
y: evt.clientY - canvas.offsetTop + window.scrollY
};
}
相關問題
- 1. Mozilla上的Font Gregor
- 2. 的JavaScript在Mozilla Firefox
- 3. Mozilla中的javascript innerHTML
- 4. Mozilla的JavaScript問題
- 5. mozilla的javascript格式
- 6. Html.DropDownListFor()在Mozilla Firefox
- 7. Radbutton Onclick mozilla bug
- 8. Mozilla Firefox bug或..?
- 9. Uploadify in mozilla
- 10. 不叫在Mozilla
- 11. Mozilla iframe滾動
- 12. Mozilla中的keyPress問題
- 13. Mozilla的進度風格
- 14. mozilla firefox意外的行爲
- 15. IE和Mozilla中的fusionchart
- 16. Mozilla Firefox瀏覽器的ActiveX
- 17. IMG的onclick = 「LinkModalDialog()」 在Mozilla
- 18. 的document.getElementById( 'rowtxtConsidAmt')空只在Mozilla
- 19. Mozilla的犀牛:以範圍
- 20. 調試新的Mozilla WebExtension API
- 21. 使用Mozilla Firefox的WebRequest
- 22. Mozilla的擴展錯誤
- 23. Python代碼從Mozilla的
- 24. SQL Reporting Services的 - 在Mozilla
- 25. Mozilla Thunderbird的原生API
- 26. mozilla彈出窗口
- 27. JavaScript函數在Mozilla
- 28. Mozilla打印預覽
- 29. (NS_ERROR_FAILURE)Mozilla瀏覽器
- 30. 開發mozilla插件
沒有人知道一些關於這個問題? – 2013-03-09 20:18:18
你的getMousePos()函數是什麼? – devnull69 2013-03-09 22:30:25
Here:http://pastebin.com/iPet57wV 但是這個功能應該沒問題。它在所有瀏覽器中顯示相同的座標 – 2013-03-10 08:04:17