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

后端 未结 11 1794
傲寒
傲寒 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

    Simple solution with Javascript which works for me and I saw no side effects in other browsers:

    <script>
      var pswElement = document.getElementById("password");
      pswElement.addEventListener("focus", myFocusFunction, true);
    
      function myFocusFunction() {    
        document.getElementById("password").select();
      }
    </script>
    

    Anyway is quite sad MS is not able fix such problem in higher version too.

    0 讨论(0)
  • 2020-12-05 14:33

    I originally wrote the plugin below to address memory leaks in IE 8, but consequently it also fixes this problem.

    https://github.com/steelheaddigital/jquery.purgeFrame

    0 讨论(0)
  • 2020-12-05 14:36

    This bug is very annoying, even worse there was very few informations we could find on google.

    There is only one link from Microsoft that about IE9, but problem still exists in IE10 / IE11 and much easier to reproduce.

    I have just create a fiddle to describe this problem

    http://jsfiddle.net/WilliamLeung/T3JP9/1/

    Why it is so hard for M$ to fix this issue for years?

    there should be three workarounds

    1. Reset the focus every time we modify the DOM with iframe
    2. or schedule a "do nothing" time consuming task, which may make IE response to mouse event magically, I could not tell you why, maybe M$ could

      The sample codes which setup a time consuming task

      setInterval(function () {
          var loopCount = 10000;
          var x = 0;
          for (var i = 0; i < loopCount; i++) {
              x = (x + Math.random() * 1000) >>> 0;
          }
          return x;
      }, 1000);
      
    3. or reset the DOM content before remove it from document

      someDivWithIframe.innerHTML = "";
      $(someDivWithIframe).remove();
      

      I am not sure if it helps for all cases, you should have a tried

    0 讨论(0)
  • 2020-12-05 14:38

    The solution with jQuery worked on IE11 for me, not the other solutions.

    $(theIframeElement).empty().remove();

    An other solution working on IE9/10 was to set the iframe src to empty before deleting it

    iframe.src=""

    But this cause an exception "Access denied" on IE11 if you are using an older jQuery version < 1.11.1

    Some links: For information, jQuery also fixed this Issue for it's Dialog.js plugin that was displaying content in an iframe: http://bugs.jqueryui.com/ticket/9122

    jQuery bug fix to IE11 "access denied" error: http://bugs.jquery.com/ticket/14535

    0 讨论(0)
  • 2020-12-05 14:38

    I had the same issue with IE11, angularjs and using an IFrame. My template uses ng-switch to change view-modes. One of the view-modes contains an IFrame. The moment I switch away from the view-mode containing the IFrame:

    var iFrame = <HTMLIFrameElement>document.getElementById("myIFrame");
    iFrame.focus();
    this.mode = ViewModes.ModeWithoutIFrame;
    

    Solved the problem for me.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题