[英]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 onlydocument
andmedia
elements). This spec showsiframe
implementsload
/onload
, but notreadyState
attribute orreadystatechange
event)." “ MSDNreadyState
属性文档指向(on)readystatechange
事件文档,该文档清楚地表明iframe支持这些功能。但是显然IE11不再支持iframe。这似乎是IE11遵循W3C规范。规范显示了全局属性和事件。(readyState
/readystatechange
不是全局的,仅命名document
和media
元素。该规范显示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]
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>
Internet Explorer Dev Center: [API Reference] readystatechange | Internet Explorer开发中心:[API参考] readystatechange | onreadystatechange event 1 onreadystatechange事件1
WebPlatform.org: readystatechange 2 WebPlatform.org:readystatechange 2
Internet Explorer Dev Center: [Community] IE11 onreadystatechange event not firing 3 Internet Explorer开发中心:[社区] IE11 onreadystatechange事件未触发3
Developer-Works.com: IE11 onreadystatechange event not firing 4 Developer-Works.com:IE11 onreadystatechange事件未触发4
尝试在document.ready中编写函数readyStateChange()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.