0

Using jQuery, I add 2 attributes to an object element like this

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

This code works on IE 7 and IE 8 but not in IE 9.

I inspected my tag using developer tools and found that the 'codebase' attribute is set and the 'onerror' attribute is not getting set in IE 9.

Any idea why I'm facing this problem only in IE 9? Thanks in advance.

4
  • codebase and onerror are not defined attributes and are custom attributes for elements. So, custom attributes are supported only from IE 9. Commented Oct 15, 2012 at 6:31
  • @Praveen: if both these attributes are not supported can you explain why the 'codebase' attribute works as expected in IE 9? Commented Oct 15, 2012 at 6:34
  • Take into account that the HTML browser from the Developer Tools is not dynamically updated like in Chrome or Firebug. I have added both attributes from code to an <img/> tag and then retrieved their values and it seems to be working, in the sense that the same values set are retrieved. Commented Oct 15, 2012 at 6:36
  • I said you it works from IE 9. Commented Oct 15, 2012 at 7:04

2 Answers 2

1

You could use the .error() event handler in jQuery. The following is an example

$('#myObject').error(function(){
  InstallFailed();
});
Sign up to request clarification or add additional context in comments.

1 Comment

not the exact answer I was looking for, but this could work! Thanks!
0

Try -

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

Demo

3 Comments

thanks for the answer mate, but that doesn't seem to set the 'onerror' attribute either, but it does set the 'codebase' attribute just as my snippet did.
@awadm Checked the demo in IE9 - Both attributes are applied to DIV
I see. Can you think of any reasons why this attribute isn't getting set to my object tag?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.