KineticJS不会在Internet Explorer中加载 [英] KineticJS wont load in Internet Explorer
问题描述
我遇到了一个非常烦人的问题-我刚刚在KineticJS中制作了一个可爱的脚本- http://test.manwe.cz/kolac.php
I got a seriously annoying problem - I just made a cute script in KineticJS - http://test.manwe.cz/kolac.php
如您所见,它在Chrome/FF中可以完美地工作,但是在IE中,它只是说我不能使用方法"indexOf"并指向Kineticjs.js内的某处... 我获得了最新的KineticJS版本,并尝试对其进行调试,看来问题出在Kinetic.Stage构造函数中.当我将其注释掉时,它可以工作(但显然其他任何方法都无法工作) 谢谢您的帮助,我有点绝望.
As You can see, it works flawlessly in Chrome/FF, but in IE it just says that I cant use the method "indexOf" and points somewhere inside the Kineticjs.js ... I got the newest KineticJS version and I tried to debug it and it looks like the problem is in the Kinetic.Stage constructor. When I comment it out it works (but obviously nothing else works then) Thanks for your help, Im kinda desperate.
推荐答案
嗯,我也遇到了同样的问题.因此,最好的办法是在javascript中添加额外的方法.
Well I am also having the same problem. So the best I've come up with adding the extra method in javascript.
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++)
{
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
这将解决indexOf问题,但是这又带来了另一个问题. 最新版本似乎添加了get"Property"()并设置了"Property"().
This will solve the indexOf problem, however that presents another issue. The lastest release seems to add get"Property"() and set"Property"().
我的猜测"是使用以下代码行的kinecticJS的一些内部工作:
My "Guess" is some of the inner workings of kinecticJS using this line of code:
this.context = this.element.getContext('2d');
在我看来"这一行应该位于
where as the line "In my humble opinion" should be
this.setContext(this.getElement().getContext('2d'));
我的另一个猜测"是无法通过更改几行代码来解决. 我对此并不完全确定.我刚刚开始研究这个问题. 我可能建议降级版本,但是我不确定这是否可以解决问题.
My other "Guess" is this can't be fixed by changing a few lines of code. I am not entirely sure on this though. I have just started to look at the issue. I might sugguest downgrading versions, but I am not sure if that will fix the problem or not.
更新:
再往前看,我发现了这篇文章 HTMLCanvas的"getContext"不是受支持的属性或方法 这意味着我以前的猜测"均不正确. 总结以上所有您需要的内容,就是您的html head数据中的这一行:
So looking a little further, I found this post HTMLCanvas 'getContext' is not a supported property or method Which means none of my previous "Guesses" are correct. Summarizing the post above all you need is this line in your html head data:
<meta http-equiv="X-UA-Compatible" content="chrome=1, IE=edge">
这解决了我在IE(版本9.0.8112.16421)中遇到的问题
This fixes the problem i have having in IE (Version 9.0.8112.16421)
这篇关于KineticJS不会在Internet Explorer中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!