找到你要的答案

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

Q:IE 9和IE 10不能输入文本到输入文本框不时

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 can be focused and not faded. There is no code to disable the input controls and this does not always happen. Up until now, this is happening only in IE 9 and IE 10. Firefox and Chrome is OK.

Brief description of how the page works is:

  • There is a button on the parent page. By clicking it will build an iframe from scratch and show it. This is done by Javascript.

  • Again, there is a button on the iframe to close it. By clicking it
    will remove the iframe from the parent page's DOM.

Please let me know if you want further information as required. Thanks in advance.

有一个iframe里面的网页。有时,输入文本框控件,里面的iframe,锁定/冻结。用户无法进入文本。但文本框可以集中,而不是褪色。没有禁用输入控件的代码,但这并不总是发生。到现在为止,这只是发生在IE 9和IE 10。火狐和Chrome没问题。

页面如何工作的简要说明:

  • There is a button on the parent page. By clicking it will build an iframe from scratch and show it. This is done by Javascript.

  • Again, there is a button on the iframe to close it. By clicking it
    will remove the iframe from the parent page's DOM.

请让我知道,如果你需要进一步的信息。先谢谢了。

answer1: 回答1:

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

这个bug是非常恼人的,更糟糕的是,很少有信息,我们可以找到谷歌。

只有一个来自微软的链接,关于IE9,但问题仍然存在在IE10 / IE11和复制更容易。

我只是创造了一个小提琴来形容这个问题

http://jsfiddle.net/williamleung/t3jp9/1/

为什么M这么多年来难以解决这个问题?

应该有三个解决方法

  1. Reset the focus every time we modify the DOM with iframe
  2. 或安排一个“无所事事”耗时的任务,这可能使IE响应鼠标事件神奇,我不能告诉你为什么,也许M美元可以

    建立耗时的任务的示例代码

    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. 或重置的DOM内容之前将它从文件

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

    我不知道它是否有助于所有的情况下,你应该有一个尝试

answer2: 回答2:

I have managed to fix this bug by setting focus back to the main page. What I have done so far is: put an HTML input textbox, which is set invisible, in the main page. When the iframe closes, I set focus back to that textbox.

Please refer following links for more information about this IE bug.

link1

link2

I have managed to fix this bug by setting focus back to the main page. What I have done so far is: put an HTML input textbox, which is set invisible, in the main page. When the iframe closes, I set focus back to that textbox.

请参阅以下链接有关此IE错误的更多信息。

link1

Link2

answer3: 回答3:

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

jQuery溶液在IE11对我来说,没有其他的解决方案。

(theiframeelement美元)。empty()。remove();

其他解决方案致力于IE9 / 10是设置iframe的src为空之前删除它

iframe src=“”。

但这导致异常的“拒绝访问”对IE11如果您使用的是旧的jQuery版本& lt;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修复到IE11的“拒绝访问”的错误:http://bugs.jquery.com/ticket/14535

answer4: 回答4:

None of the solutions worked for me in IE 11.

Solved it by adding this code inside iframe:

$("input").first().focus().blur();

Obviously, this won't work if you don't have control over your iframe.

没有解决方案为我在IE 11。

解决了通过添加此代码在iframe:

$("input").first().focus().blur();

显然,这不会工作,如果你没有在你的iframe控制。

answer5: 回答5:

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

我最初写的插件,以解决内存泄漏IE 8,但它也解决了这个问题。

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

answer6: 回答6:

I was also suffering from this issue. As William Leung has pointed, IE has a bug with remove Iframe Object from DOM.

Try the following:

$(someDivWithIframe).empty().remove();

我也遭受了这个问题。正如William Leung所指出的,即有一个漏洞,从DOM去除IFRAME对象。

尝试以下:

$(someDivWithIframe).empty().remove();
answer7: 回答7:

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.

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;

为我解决问题。

javascript  html  internet-explorer  internet-explorer-9  internet-explorer-10