IE 9 and IE 10 cannot enter text into input text boxes from time to time

后端 未结 11 1864
傲寒
傲寒 2020-12-05 13:59

There is a web page with an iframe inside. Sometimes, Input text box controls, inside the iframe, are locked/ freezed. Users cannot enter text into them. But the text box ca

11条回答
  •  盖世英雄少女心
    2020-12-05 14:26

    Just to add to what others said, it is actually a problem when some input in an iframe is having focus which is then closed causing all other inputs to lose focus. And indeed having a script to set focus to an element solves the problem. But for me this wasn't working because some of my inputs were disabled. So the solution that worked for me is below

    $("input[type=text]:not([disabled])").first().focus();
    

    Complete snippet as I was using bootstrap modal and the modal had an iframe. I set the focus to an editable field before opening a model and after closing:

    var modalInstance = $uibModal.open({
        // modal properties
      });
    modalInstance.closed.then(function () {
      $("input[type=text]:not([disabled])").first().focus();
    });
    modalInstance.opened.then(function () {
      $("input[type=text]:not([disabled])").first().focus();
    
    });
    

提交回复
热议问题