Html5 canvas HTML5可以';在IE 8和IE 7中使用Webshims无法使画布正常工作
我知道我在做一些非常愚蠢的事情,所以我希望第二双眼睛能指出我的愚蠢。我正试图让Webshims polyfill在一个简单的画布测试上工作(我第一次接触它)。在Chrome和IE9中效果很好,但在IE8和IE7(开发工具)中进行测试时,我发现错误: 对象不支持属性或方法“getContext” 这是我的密码Html5 canvas HTML5可以';在IE 8和IE 7中使用Webshims无法使画布正常工作,html5-canvas,polyfills,Html5 Canvas,Polyfills,我知道我在做一些非常愚蠢的事情,所以我希望第二双眼睛能指出我的愚蠢。我正试图让Webshims polyfill在一个简单的画布测试上工作(我第一次接触它)。在Chrome和IE9中效果很好,但在IE8和IE7(开发工具)中进行测试时,我发现错误: 对象不支持属性或方法“getContext” 这是我的密码 <!DOCTYPE html> <html> <head> <script src="http://ajax.googlea
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="js-webshim/minified/extras/modernizr-custom.js"></script>
<script>
// set options for html5shiv
if(!window.html5){
window.html5 = {};
}
window.html5.shivMethods = false;
</script>
<script src="js-webshim/minified/polyfiller.js"></script>
<script class="example">
window.FlashCanvasOptions = {
disableContextMenu: true
};
$.webshims.setOptions({
waitReady: false
});
$.webshims.polyfill();
</script>
</head>
<body>
<canvas id="my-canvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
var ctx = $('#my-canvas').getContext('2d');
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
ctx.fillRect (30, 30, 55, 50);
window.FlashCanvasOptions = {disableContextMenu: true};
$.webshims.setOptions('canvas', {type: 'excanvas'});
</script>
</body>
</html>
我在BrowserStack中进行了测试,得到了相同的结果。我做错了什么?我很高兴把我的朦胧暴露出来,让所有人都能看到 您必须删除waitReady或将其设置为true。您必须删除waitReady或将其设置为true。这已经有很长时间了,但这可能会对某些人有所帮助 我遇到了完全相同的错误-没有记录错误,但画布上也没有显示任何内容 这是通过添加
<meta http-equiv="X-UA-Compatible" content="IE=7">
这已经有很长时间了,但也许这会对某些人有所帮助 我遇到了完全相同的错误-没有记录错误,但画布上也没有显示任何内容 这是通过添加
<meta http-equiv="X-UA-Compatible" content="IE=7">
我试过了-请参见第二段代码片段。我没有得到一个错误,但也没有得到画布渲染。无论如何,谢谢…我试过了-请看第二段代码。我没有得到一个错误,但也没有得到画布渲染。不管怎样,谢谢你……我记不起我做了什么,但我已经成功了。那是很久以前的事了!但无论如何,谢谢。我记不起我做了什么,但我成功了。那是很久以前的事了!不过还是谢谢你