aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTJ VanToll <tj.vantoll@gmail.com>2013-08-28 09:17:01 -0400
committerTJ VanToll <tj.vantoll@gmail.com>2013-08-28 11:35:21 -0400
commiteae2c4b358af3ebfae258abfe77eeace48fcefcb (patch)
treeed545d8ffdf2c8f32fc363cf813068973c9444b1
parent643ef44ee2ed4fa5176ad76d69f855b0d97486cc (diff)
downloadjquery-ui-eae2c4b358af3ebfae258abfe77eeace48fcefcb.tar.gz
jquery-ui-eae2c4b358af3ebfae258abfe77eeace48fcefcb.zip
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
-rw-r--r--ui/jquery.ui.draggable.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 2bdc20255..3b18f28f0 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -76,9 +76,19 @@ $.widget("ui.draggable", $.ui.mouse, {
_mouseCapture: function(event) {
- var o = this.options;
-
- $( document.activeElement ).blur();
+ var document = this.document[ 0 ],
+ o = this.options;
+
+ // support: IE9
+ // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
+ try {
+ // Support: IE9+
+ // If the <body> is blurred, IE will switch windows, see #9520
+ if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
+ // Blur any element that currently has focus, see #4261
+ $( document.activeElement ).blur();
+ }
+ } catch ( error ) {}
// among others, prevent a drag on a resizable-handle
if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {