有時候我有些象這樣的錯誤之一,當我與畫布上的Firefox工作:火狐帆布工作時拋出錯誤0x80004005
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMCanvasRenderingContext2D.lineWidth]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: media/js/canvas/Rectangle.js :: :: line 34" data: no]
它發生時,我正在與超過5種畫布元素的工作,上一個for循環。創建它們的函數是這樣的:
function addCanvas(id) {
var canvas = document.getElementById(id);
if (canvas == null) {
$('#content').append(
'<canvas id="' + id + '" width="' + workAreaWidth +'" height="'
+ workAreaHeight + '"></canvas>'
);
canvas = document.getElementById(id).getContext('2d');
} else {
canvas = canvas.getContext('2d');
canvas.setTransform(1, 0, 0, 1, 0, 0);
canvas.clearRect(0, 0, workAreaWidth, workAreaHeight);
}
return canvas;
}
for循環在另一個函數中。
會發生什麼,並非所有的畫布元素都被更新。我猜是例外的原因。
我無法發佈完全失敗的地方的代碼,導致它在許多地方隨機失敗,總是出現相同的錯誤。
Firefox版本是9.0,但也發生在8.0.1上。我沒有在以前的版本上測試它。我的操作系統是Mac Snow Leopard。我想這會有所幫助。它不會在Chrome或Safari上失敗,
感謝您的幫助。
什麼是'for bucle'? (你的意思是'循環'?) – zwol 2011-12-28 20:55:26
是的,抱歉...我不是英語。生病編輯帖子糾正它。 – elxordi 2011-12-28 21:08:41