HGPB
HGPB

Reputation: 4376

Jquery-ui creates unspecified error when loading iFrame in IE9

I'm loading the latest jQuery and jQuery-ui inside an iFrame in IE9.

I get an unspecified error regarding the active = document.activeElement;. If I delve into the jquery-ui code and return null:

active = null;

This solves my problem as it seems document.activeElement is not set in IE9 when initiated from within an iFrame.

I have also read similar issues elsewhere:

https://github.com/jquery/jquery-mobile/issues/2064

I don't really want to edit jquery-ui with a try/catch but it is an option.

What is the best solution to this problem?

Upvotes: 4

Views: 3166

Answers (2)

HGMamaci
HGMamaci

Reputation: 1396

Read http://bugs.jquery.com/ticket/13378

Best solution is to place following script within the iFrame HTML

/* Bug Fix: IE9 >>> http://bugs.jquery.com/ticket/13378 */
jQuery(function () { document.documentElement.focus(); });

Upvotes: 4

PEtter
PEtter

Reputation: 846

I belive the problem is IE9 loading the "src" of the iframe before it is attached to the DOM, and then jQuery does not have a "document".

Upvotes: 1

Related Questions