Skip to main content

Bug Tracker

Side navigation

#13378 closed bug (wontfix)

Opened February 04, 2013 02:43AM UTC

Closed April 08, 2013 07:39PM UTC

Last modified April 08, 2013 10:52PM UTC

ie8 & ie9 iframe - .filter(":focus") - document.activeElement returns unspecified error.

Reported by: muzzamo Owned by: timmywil
Priority: low Milestone: 1.10
Component: selector Version: 1.9.0
Keywords: Cc: timmywil
Blocked by: Blocking:
Description

Unfortunately I am unable to put this into jsfiddle/jsbin due to issues with scripts in iframes on both of these sites. It can be reproduced if you place the following two files in a folder on the file system and open outer.html in ie9:

outer.html

<!DOCTYPE html>
<html lang="en">
<body>

	<div style="border: 1px solid black">
    <iframe src="inner.html" style="width:1024px; height:768px;"></iframe>

    </div>
   
</body>
    
</html>

inner.html

<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<!--<script src="http://code.jquery.com/jquery-git.js"></script>-->
</head>
<body>

<a id="link" href="http://www.google.com">google</a> 
<script>
       $("#link").filter(":focus");
</script>
</html>

To make sure that internet explorer executes scripts when loaded this way go to internet options -> advanced -> security -> "Allow active content to run in files on My Computer*". Then when you load the page in ie, a popup will appear at the bottom saying "Internet explorer restricted this webpage from running scripts or ActiveX controls.", click "Allow blocked content".

Make sure the script debugger is enabled (F12 developer tools -> script -> start debugging).

This is occurring on line 4869 of jquery-1.9.0.js.

This also occurred on jquery 1.8.x.

This is also occurring in jquery-git.js v 2013-2-3 on line 4877.

This occurs on ie8 and ie9 (ie7, ie10 not tested), and does not occur on firefox and chrome.

I believe this was first reported in jquery UI ticket 8443 (http://bugs.jqueryui.com/ticket/8443) which was closed due to not enough information. The issue applies to jquery core.

The workaround for this bug is to add the following to the iframe.html file:

<script>
             jQuery(function () { document.documentElement.focus(); });
        </script>

This issue was first reported as a defect in kendo UI v2012.3.1315 in the menu widget, which depends on JQuery 1.8.x.

Attachments (0)
Change History (17)

Changed February 04, 2013 10:23PM UTC by anonymous comment:1

I have now created a jsfiddle for this as well.

Make sure the script debugger is enabled in ie.

http://jsfiddle.net/muzzamo/2taTW/

Changed February 08, 2013 10:23PM UTC by gibson042 comment:2

cc: → timmywil
component: unfiledselector
priority: undecidedlow
status: newopen

The exception is thrown on ''access'' of document.activeElement in the framed page, and document.hasFocus() frustratingly returns true. We can either stick a try…catch in the ":focus" filter or wontfix this ticket, but I don't see a third option.

Changed February 21, 2013 10:33AM UTC by azkme comment:3

One remark on this one: it doesn't always occur though. If I open the page in IE9 on the webserver itself, there are no problems for me. This only occurs when I try opening a page from another location as the webserver (beats me).

Changed March 11, 2013 03:31PM UTC by nikolay.r.rusev@gmail.com comment:4

I use to have the same issue. As far as my experience I found two workarounds for this problem:

  • call document.documentElement.focus() - this will somehow force document invalidation
  • use document.documentElement.activeElement instead of document.activeElement

Hope it help someone.

Changed March 11, 2013 05:52PM UTC by johnny_reilly@hotmail.com comment:5

I've been experiencing a very similar issue with an IFrame on IE when calling the following bit of code:

$("input[autofocus]").focus();

This blows up on line 3254 of jquery-1.9.1.js, apparently on the following command:

(this !== document.activeElement)

Would be great if this could be fixed....

Changed March 15, 2013 06:26AM UTC by anonymous comment:6

Replying to [comment:4 nikolay.r.rusev@…]:

I use to have the same issue. As far as my experience I found two workarounds for this problem: - call document.documentElement.focus() - this will somehow force document invalidation - use document.documentElement.activeElement instead of document.activeElement Hope it help someone.
=
  • use document.documentElement.activeElement instead of document.activeElement

This works for me. Thanks for the post!

Van Thi

Changed March 20, 2013 07:01PM UTC by mattfaus@khanacademy.org comment:7

This has caused several high-priority problems for us in the past few weeks. I think the priority of this bug should be escalated.

Thanks to those who have posted workarounds though!

Changed March 21, 2013 07:55AM UTC by xfinx comment:8

Thanks for the workarounds! Recently upgraded to 1.9.1 and our gallery (which is loaded in an iframe) stopped working.

I would love to see this one fixed.

Thanks!

Changed March 25, 2013 04:22PM UTC by timmywil comment:9

owner: → timmywil
status: openassigned

Changed April 08, 2013 06:17PM UTC by Timmy Willison comment:10

resolution: → fixed
status: assignedclosed

Update Sizzle: use documentElement in focus selector. Fixes #13378.

Changeset: aadae5058a44e745ebdbee5d5333402699326188

Changed April 08, 2013 06:26PM UTC by dmethvin comment:11

milestone: None1.10

Changed April 08, 2013 07:23PM UTC by timmywil comment:12

resolution: fixed
status: closedreopened

Changed April 08, 2013 07:25PM UTC by timmywil comment:13

Unfortunately, the test that made sure that it didn't throw an error was passing because documentElement.activeElement is just undefined. We will not be fixing this because the only solutions are either a try/catch or calling document.focus(), neither of which we are willing to do. However, we had bypassed QSA for all :focus selectors due to a Chrome bug. We will instead let :focus always pass through QSA so IE doesn't throw an error (except in a few edge cases), but Chrome will be wrong sometimes.

Changed April 08, 2013 07:39PM UTC by timmywil comment:14

resolution: → wontfix
status: reopenedclosed

Changed April 08, 2013 07:52PM UTC by m_gol comment:15

_comment0: If Chrome has a bug here it should probably be reported to them and linked to this meta bug:[[BR]] \ https://code.google.com/p/chromium/issues/detail?id=176671[[BR]] \ (I'm not doing it myself because I don't know the details of this bug). \ \ Fortunately, if/when they fix it this problem just disappears for us because of Chrome rapid release pace; can't say the same about IE.1365461522686297

If Chrome has a bug here it should probably be reported to them and linked to this meta bug:

https://code.google.com/p/chromium/issues/detail?id=176671

(I'm not doing it myself because I don't know the details of this bug).

Fortunately, if/when they fix it this problem just disappears for us because of Chrome rapid release pace; can't say the same about IE.

Changed April 08, 2013 08:46PM UTC by timmywil comment:16

The bug has been fixed in browsers that jQuery supports. It is only an issue for Sizzle.

Changed April 08, 2013 10:52PM UTC by m_gol comment:17

Ah, ok.