쿠키에서 캔버스 데이터를로드하려고 할 때 문제가 발생하지만 데이터를로드 할 때 다음 오류가 발생합니다. 내가 뭘하려고 오전HTML 쿠키에서 캔버스 데이터로드 중
Uncaught TypeError: Failed to execute 'putImageData' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.
다른 버튼 내가 읽은 후 캔버스에이 데이터를 다시 그려야 할을 누를 때 버튼이 다음 누를 때 쿠키에 캔버스 데이터를 저장합니다. 쿠키를 저장할 때이 내 코드
context.putImageData(canvasRead, 0, 0);
입니다 :
if (document.getElementById('hdnSwitchButton').getAttribute("Value") == 0) {
canvas.style.zIndex = "-2";
} else if (document.getElementById('hdnSwitchButton').getAttribute("Value") == 1) {
canvas.style.zIndex = "0";
canvasRead = getCookie("canvas");
if (!canvasRead) {
alert('Error: Cannot read canvas!');
} else {
context.putImageData(canvasRead, 0, 0);
}
}
이가 쿠키를 읽고 오류가 라인에 발생하는 위치 내 initiliase 코드
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
function BrowserButtonClick() {
document.getElementById('hdnSwitchButton').setAttribute('Value', 0);
canvasSave = context.getImageData(0, 0, aWidth, aHeight);
document.cookie = "canvas=" + canvasSave;
}
그리고 내 html 캔버스 코드는 다음과 같습니다 :
<div class="canvas">
<canvas id = "DrawingCanvas">
<p>Unfortunately, your browser is currently unsupported by our web application. We are sorry for the inconvenience. Please use one of the supported browsers listed below.</p>
<p>Supported browsers: <a href="http://www.google.com/intl/en_uk/chrome/browser/">Chrome</a>, <a href="http://www.opera.com">Opera</a>, <a href="http://www.mozilla.com">Firefox</a>, <a href="http://www.apple.com/safari">Safari</a>, and <a href="http://www.konqueror.org">Konqueror</a>.</p>
</canvas>
</div>
내가 알고 싶은 것은 왜 이런 일이 일어나는가와 문제없이 캔버스에서 캔버스 데이터를로드하는보다 효율적인 방법으로 쿠키에서 내 캔버스를로드하는 방법입니다.