Skip to content

Commit eae2c4b

Browse files
committed
Draggable: Safe activeElement access from iFrames for IE9, prevent window focus changes in IE9+. Fixed #9520 - Draggable: Browser window drops behind other windows in IE9/10
1 parent 643ef44 commit eae2c4b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ui/jquery.ui.draggable.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,19 @@ $.widget("ui.draggable", $.ui.mouse, {
7676

7777
_mouseCapture: function(event) {
7878

79-
var o = this.options;
80-
81-
$( document.activeElement ).blur();
79+
var document = this.document[ 0 ],
80+
o = this.options;
81+
82+
// support: IE9
83+
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
84+
try {
85+
// Support: IE9+
86+
// If the <body> is blurred, IE will switch windows, see #9520
87+
if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
88+
// Blur any element that currently has focus, see #4261
89+
$( document.activeElement ).blur();
90+
}
91+
} catch ( error ) {}
8292

8393
// among others, prevent a drag on a resizable-handle
8494
if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {

0 commit comments

Comments
 (0)