我的页面在 IE9、Safari、Chrome 和 Firefox 中完美加载。
但是当它到 IE10 时,它会抛出错误: 无法 在d3.v3.js中获取属性“原型”的未定义或空引用 :d3_window.CSSStyleDeclaration.prototype。
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
} catch (error) {
var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
d3_style_prototype.setProperty = function(name, value, priority) {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
我没有得到这里到底在做什么。
在尝试块中,即使 setProperty 方法我们可以在调试器中看到d3_document.createElement("div").style
它抛出错误:
对象不支持属性或方法'setProperty'
在 catch 块中,它尝试访问 window 的原型CSSStyleDeclaration
,但这是未定义的。