1

I have encountered an interesting problem. I am using an iframe to display a page of my site. I load jquery this way:

<script type="text/javascript" src="/js/lib/jquery-1.10.1.min.js"></script>

The library is at the place where I have been referring to. However, when IE tries to load jQuery, I get the error:

Object doesn't support property or method 'attachEvent'.

I have been looking at this question, however, the proposed solution had no effect on the error shown above. I have already loaded jQuery from my project, as shown in the html snippet. I have tried to download jquery-1.8.3.js, but when tested, I got the same problem.

My page displayed in the iframe works perfectly under Chrome and FireFox. Is there a solution to my problem or should I start the Blair Witch project and modify my code to have no jQuery-specific part in it?

Community
  • 1
  • 1
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • Which version of IE? What exactly is the "object" not supporting `attachEvent`? – Teemu Jun 11 '14 at 04:36
  • I have tested with IE 11. It is an object inside jQuery. – Lajos Arpad Jun 11 '14 at 05:23
  • 1
    jQuery 1.10 has caused some troubles in IE11, use version `1.11.0` or newer. – Teemu Jun 11 '14 at 05:32
  • @teemu, that's not an option. I am not an IE user, but I am testing my work in IE. I cannot determine who will be the users so I can see two options: 1. I can try to hack jQuery to fix the bug. 2. I can rewrite my Javascript used at the page being the source of the iframe to not use jQuery. I would like to know if there is a not too painful solution, this is why I asked the question. – Lajos Arpad Jun 11 '14 at 15:42
  • Well, you can fix the erranous part only, though I can't understand, why not use the updated version? In 1.10.1 search for `// Set our document` (line 1503), starting from line 1513 there's an `if` block, which you've to replace with an `if` block from version 1.11.1 (starting from line 1069). – Teemu Jun 12 '14 at 04:29
  • @teemu, for some reason I was reading that I should update the IE version while you clearly did not write that. My apologies, I guess I have worked too much yesterday. – Lajos Arpad Jun 12 '14 at 13:15
  • @Teemu, if you convert your comment to an answer, I will accept it. Upgrading jquery version was the solution indeed. – Lajos Arpad Jun 13 '14 at 11:59

1 Answers1

2

Your problem with IE is caused by the MS policy, which is bringing IEs closer to the standards. A part of it is to drop some legacy features from new versions. For example conditional comments were dropped out from IE10, the legacy event handling model is not supported by IE11 anymore, etc.

For some reason jquery <= 1.10.1 still uses the legacy event handling model in some IE specific code (not feature detected). These are fixed in version 1.11.0 and newer.

Teemu
  • 22,918
  • 7
  • 53
  • 106