2
아래 코드는 모든 브라우저에서 정상적으로 열리지 만 WPF 웹 브라우저 컨트롤에서 코드를 실행하려고하면 Javascript 오류가 발생합니다. "canvas.getContext ("2d ") 정의되지 않았습니다."canvas.getContext ("2d")가 정의되지 않았습니다.
<html>
<head>
<title>Bar Chart</title>
<script src="Chart.js" type="text/javascript"></script>
<script type="text/javascript">
var canvas = null;
var context = null;
window.onload = function() {
invokeService();
canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
alert(context);
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Bar(barChartData);
};
var barChartData;
function invokeService() {
alert("q");
barChartData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,1)",
data: [65, 59, 90, 81, 56, 55, 40]
},
{
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 96, 27, 100]
}
]
}
}
</script>
</head>
<body>
<canvas id="canvas" height="450" width="600"></canvas>
</body>
</html>
편집 1 : chart.js 여기 https://github.com/nnnick/Chart.js
를 추가하여이 문제를 해결했다. 나는 IE가 'WebBrowser' 컨트롤로 호스팅 될 때 [IE7 ** 모드로 기본 설정 됨] (http://stackoverflow.com/questions/4097593/how-to-put-the-webbrowser-control)을 알았습니다. ie-ie-into-standards) (IE9 모드에 놓일 위험이없고 IE * 7로 쉽게 변경 될 수없는 오래된 비평 기반 비즈니스 응용 프로그램이라는 가정하에) . * "WPF 웹 브라우저"*는 실제로 WPF 응용 프로그램에서 호스팅되는 Internet Explorer입니까? –
* [user3779105] 질문 (http://stackoverflow.com/users/3779105/user3779105) : * 태그를 정확히 어디에 추가 했습니까? –
@ArtjomB. '
...' – Griddo