IE 9 和 IE 10 时不时无法在输入文本框中输入文本 [英] IE 9 and IE 10 cannot enter text into input text boxes from time to time

查看:23
本文介绍了IE 9 和 IE 10 时不时无法在输入文本框中输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个带有 iframe 的网页.有时,iframe 内的输入文本框控件被锁定/冻结.用户无法在其中输入文本.但是文本框可以聚焦而不褪色.没有禁用输入控件的代码,这并不总是发生.到目前为止,这仅在 IE 9 和 IE 10 中发生.Firefox 和 Chrome 没问题.

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:

  • 父页面上有一个按钮.通过单击它将构建一个从头开始 iframe 并显示它.这是由 Javascript 完成的.

  • 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.

同样,iframe 上有一个按钮可以关闭它.通过点击它
将从父页面的 DOM 中删除 iframe.

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.

推荐答案

这个bug很烦人,更糟糕的是我们在google上能找到的信息很少.

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

微软只有一个关于IE9的链接,但IE10/IE11问题依然存在,而且更容易重现.

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/

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

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

应该有三种解决方法

  1. 每次我们使用 iframe 修改 DOM 时重置焦点
  2. 或者安排一个什么都不做"的耗时任务,这可能会使 IE 神奇地响应鼠标事件,我无法告诉你为什么,也许 M$ 可以

  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);

  • 或者在将 DOM 内容从文档中删除之前重置它

  • 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

    这篇关于IE 9 和 IE 10 时不时无法在输入文本框中输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆