试试这段代码,肯定会对你有用:
Game Stagefunction loadCanvas(id) {
var canvas = document.createElement('canvas');
div = document.getElementById(id);
canvas.id = "CursorLayer";
canvas.width = 1224;
canvas.height = 768;
canvas.style.zIndex = 8;
canvas.style.position = "absolute";
canvas.style.border = "1px solid";
div.appendChild(canvas)
}
The most important heading on this page
With some supplementary information
loadCanvas("divGameStage");
有些事情要记住:
1.错误No 1缺少loadCanvas(“divGameStage”)中的引号;
2.错误No 2是语法错误div = document.getElementById(id); “..ID(id)”在您的代码中.
如果那时它也不起作用那么我确定你在Internet Explorer上测试它(特别是< IE9)
– 如果是这种情况,FYI IE9及以上支持画布没有其他较小版本支持画布
干杯!!!