0

使用 jQuery,我向这样的对象元素添加 2 个属性

$('#myObject').attr('codebase', pluginURL_IE);
$('#myObject').attr('onerror', 'InstallFailed();');

此代码适用于 IE 7 和 IE 8,但不适用于 IE 9。

我使用开发人员工具检查了我的标签,发现“codebase”属性已设置,而“onerror”属性未在 IE 9 中设置。

知道为什么我只在 IE 9 中遇到这个问题吗?提前致谢。

4

2 回答 2

1

您可以在 jQuery 中使用 .error() 事件处理程序。下面是一个例子

$('#myObject').error(function(){
  InstallFailed();
});
于 2012-10-15T08:35:56.150 回答
0

尝试 -

$('div').attr({codebase: 'pluginURL_IE', onerror: 'InstallFailed();' });

演示

于 2012-10-15T06:38:59.527 回答