HTMLCanvas'getContext'不是受支持的属性或方法 [英] HTMLCanvas 'getContext' is not a supported property or method

查看:1076
本文介绍了HTMLCanvas'getContext'不是受支持的属性或方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚刷了一个HTML5游戏应用程序,我一直收到'对象不支持来自一些用户的属性或方法的getContext 错误日志。

I've just lauched a HTML5 game application, and I keep receiving 'object doesn't support property or method 'getContext' errors logs from some of my users.

我的设置仅允许使用Chrome(16 <),Firefox(9 <)或IE(9 <)玩游戏的用户。
IE(< 9)用户在他们的脸上安装了一个chromeframe。

My setup only allows users with Chrome (16<), Firefox (9<) or IE (9<) to play the game. IE (<9) users gets a chromeframe installation in their face.

它只有一些IE9用户抛出这个异常。
我在几个Windows机器上使用IE9,vista和windows 7玩游戏。

Its only some of my IE9 users that throw this exception. I've played the game on several windows machines with IE9, both vista and windows 7.

搜索我的源代码,调用getContext函数相同的模式。
我使用document.createElement创建一个canvas元素,然后调用getContext('2d'),下一行。

Searching my source, for the function call getContext, I get the same pattern. I create a canvas element using document.createElement, and then i call getContext('2d'), the next line.

var buffer = /** @type {!HTMLCanvasElement} */ (document.createElement('canvas')),
    ctx = /** @type {!CanvasRenderingContext2D} */ (buffer.getContext('2d')),
    draw = function(ctx) {
       /**
        * Alot of drawing calls.
        */
    };
draw(ctx);

考虑到我的IE9用户运行的游戏,因为它应该,我不认为是我的代码的一个问题,而是IE9中的一些工具栏/插件或设置,在这里跳过我。

Given that alot of my IE9 users run the game as it should, i don't think that this is a problem with my code, but rather some toolbar/plugin or setting in IE9 that is tripping me here.

你们认为什么?

推荐答案

插入边缘> 我们已经减少了很多bug计数,我们还有几个,但是可能是用户登录与奇怪的浏览器,chromeframe安装检查没有捕获。

After inserting <meta http-equiv="X-UA-Compatible" content="chrome=1, IE=edge"> we have reduced the bug count a lot, we still have a few, but that could be users logging in with weird browsers that the chromeframe install check doesn't catch.

chrome = 1表示使用chrome框架。

chrome=1 means 'use chrome frame' if its there.

IE = edge表示'使用最高版本的IE '。

IE=edge means 'use highest possible version of IE'.

现在我就去。

这篇关于HTMLCanvas'getContext'不是受支持的属性或方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆