浏览代码

Update js/jquery.inputmask.js

IE9 throw "Unspecified error" if document.activeElement is undefined when we are in an IFrame.
Robin Herbots 13 年之前
父节点
当前提交
1e3d00cc4c
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      js/jquery.inputmask.js

+ 7 - 1
js/jquery.inputmask.js

@@ -666,7 +666,13 @@
 
                 //apply mask
                 lastPosition = checkVal(el, buffer, true);
-                if (document.activeElement === el) { //position the caret when in focus
+
+   		// Wrap document.activeElement in a try/catch block since IE9 throw "Unspecified error" if document.activeElement is undefined when we are in an IFrame.
+		var activeElement;	
+		try {		    		
+		   activeElement = document.activeElement;
+		} catch(e) {}
+                if (activeElement === el) { //position the caret when in focus
                     $input.addClass('focus.inputmask');
                     caret(el, lastPosition);
                 } else if (opts.clearMaskOnLostFocus) {