Browse Source

Update js/jquery.inputmask.js

IE9 throw "Unspecified error" if document.activeElement is undefined when we are in an IFrame.
Robin Herbots 13 years ago
parent
commit
1e3d00cc4c
1 changed files with 7 additions and 1 deletions
  1. 7 1
      js/jquery.inputmask.js

+ 7 - 1
js/jquery.inputmask.js

@@ -666,7 +666,13 @@
 
 
                 //apply mask
                 //apply mask
                 lastPosition = checkVal(el, buffer, true);
                 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');
                     $input.addClass('focus.inputmask');
                     caret(el, lastPosition);
                     caret(el, lastPosition);
                 } else if (opts.clearMaskOnLostFocus) {
                 } else if (opts.clearMaskOnLostFocus) {