我对 javascript 很陌生,所以请原谅我的无知。
我目前正在使用 SWFAddress 为 Flex 应用程序构建深度链接。问题是浏览器历史记录功能在 IE9 中不起作用。
我想解决这个问题,而且看起来这应该不是什么难事。
当我在 Firefox 中调试脚本时,收到以下错误消息:
Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMEventTarget.dispatchEvent]
this.dispatchEvent(new SWFAddressEvent(type));
这表明这段代码是罪魁祸首:
_dispatch = function(type) {
this.dispatchEvent(new SWFAddressEvent(type));
type = type.substr(0, 1).toUpperCase() + type.substr(1);
if(typeof this['on' + type] == FUNCTION)
this['on' + type]();
},
我已检查并确认 SWFAddressEvent 对象已正确实例化,没有任何问题。
问题似乎出在这里:
this.dispatchEvent = function(event) {
console.log(event);
if (this.hasEventListener(event.type)) {
console.log(event);
event.target = this;
for (var i = 0, l; l = _listeners[event.type][i]; i++)
l(event);
return TRUE;
}
return FALSE;
};
似乎由于某种原因,dispatchEvent
没有收到创建的 SWFAddressEvent
。
有人可以解释一下该错误消息的含义吗?为什么当页面首次加载时,它能够正确调度 3 个事件,但是当涉及调度更多事件时,它似乎失败了?
最佳答案
在我看来,问题在于对 this
的引用:
this.dispatchEvent(new SWFAddressEvent(type));
这部分是在事件处理程序中执行的,因此这不是 SWFAddress
,而是 Window
。
我将其替换为 SWFAddress.dispatchEvent(new SWFAddressEvent(type));
并修复了它 - 悬停我不是 JS 专家。
前三个事件的生成方式与创建 NS_ERROR_ILLEGAL_VALUE
的方式不同。
关于javascript - 组件返回失败代码: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMEventTarget.dispatchEvent],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7820381/