나는 이상한 문제에 시달리고있다 : 코드는 캔버스 요소에 액세스 할 수 없다. 다음 코드를 고려하십시오.html5 캔버스에 액세스 할 수 없습니까?
Firefox는 오류 메시지가 this.canvas is null
이됩니다. 하지만 이렇게 쓰는다면 :
this.canvas = $('#canvas');
this.context2D = this.canvas.getContext('2d');
파이어 폭스는 getContext is not a method
이라고 말할 것입니다. 나는 this.canvas
을 들여다 보았고 익숙지 않은 개체 (그것이 어디에서 왔는지 알 수는 없지만 캔버스는 아님)를 봅니다.
그리고 파이어 폭스에만 국한되는 것은 아니며 크롬도 동일한 결과를 산출합니다. 나는 이것에 미치고있다.
편집 : 전체 HTML은 여기
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Background test</title>
<script type="text/javascript" src="Scripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="Scripts/soundmanager2.js"></script>
<script type="text/javascript" src="Scripts/base.js"></script>
<script type="text/javascript" src="Scripts/Resources.js"></script>
<script type="text/javascript" src="Scripts/Actor.js"></script>
<script type="text/javascript" src="Scripts/Commons.js"></script>
<script type="text/javascript" src="Scripts/Graphics.js"></script>
<script type="text/javascript" src="Scripts/Utils.js"></script>
<script type="text/javascript">
window.onload = function(){
new Commons().startupCommons();
new Graphics().startupGraphics();
}
</script>
<style type="text/css">
body { font-family: Arial,Helvetica,sans-serif;}
canvas {border-style:solid; border-width:5px; border-color:green;}
</style>
</head>
<body>
<canvas id="visualcanvas" width="800" height="600">
<p>
Your browser does not support the canvas element.
</p>
</canvas>
</body>
</html>
난 그냥 창로드를 추가하지만 문제는 지속. 이전 코드의 this
은 Graphics 객체를 참조합니다.이 객체는 window.onload
이 호출 될 때 호출됩니다.
HTML을 볼 수 있습니까? –
'이'란 무엇입니까? - –
어디에서 코드를 업로드 할 수 있습니까? – Khoi