简体   繁体   English

在IE11中,javascript中未触发事件

[英]In IE11, event is not firing in javascript

Tried not working this is an compatability issue Ie9 vs IE11: 尝试不起作用,这是IE9与IE11的兼容性问题:

<iframe name="testwindowframe" id="testwindowframe" Onload="readyStateChange()" width="100%" height="90%"></iframe> 

Actual JSP: Please find the details :WHERE IFRAME AND SCRIPTS used this is an compatibility issue in IE11. 实际的JSP:请查找详细信息:WHERE IFRAME AND SCRIPTS使用的:WHERE IFRAME AND SCRIPTS这是IE11中的兼容性问题。 I placed a breakpoint in the readyStateChange() but its not triggering. 我在readyStateChange()放置了一个断点,但是没有触发。

<script language="javascript">
    function readyStateChange() {
        console.log('REACHED!');
    }
</script>

<iframe name="testwindowframe" id="testwindowframe" onreadystatechange="readyStateChange()" width="100%" height="90%"></iframe>

The attributes and event associated with checking the ready-state changes for <iframe> have been discontinued by Internet Explorer 11. Internet Explorer 11 中断了与检查<iframe>的就绪状态更改相关的属性和事件。

The following sums this up: 下面总结一下:

"The MSDN readyState property documentation points to the (on)readystatechange event documentation, which plainly states that an iframe supports these things. But it apparently doesn't anymore with IE11. It looks like IE11 is following W3C specs for this particular thing. This spec showsglobal attributes and events. ( readyState / readystatechange isn't global, naming only document and media elements). This spec shows iframe implements load / onload , but not readyState attribute or readystatechange event)." “ MSDN readyState属性文档指向(on)readystatechange事件文档,该文档清楚地表明iframe支持这些功能。但是显然IE11不再支持iframe。这似乎是IE11遵循W3C规范。规范显示了全局属性和事件。( readyState / readystatechange不是全局的,仅命名documentmedia元素。该规范显示iframe实现了load / onload ,但没有实现readyState属性或readystatechange事件)。” [4] [4]

"The point is that the onreadystatechange event is not being adopted by W3C since ages! And the result: IE11 has finally dropped it!" “关键是自从很久以来W3C就没有采用onreadystatechange事件!结果:IE11终于放弃了它!” [4] [4]

Also note that dynamically attaching an event on an iframe is inadvisable due to security and cross-domain restrictions when attempting to access a frame. 另请注意,由于尝试访问框架时的安全性和跨域限制,建议不要在iframe上动态附加事件。 [5] [5]

Example

This code following code works in IE11, it will produce an alert when the <iframe> is loading. 此代码后面的代码在IE11中有效,加载<iframe>时将产生警报。

 function readyStateChange() { alert('The document ready state is "' + document.readyState + '".'); } 
 <iframe name="pdfFrame" id="pdfFrame" onReadyStateChange="readyStateChange()" width="100%" height="90%"></iframe> 

Sources 资料来源

Documentation 文献资料

Forum Questions 论坛问题

Stack Questions 堆栈问题

尝试在document.ready中编写函数readyStateChange()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM