最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

internet explorer - In IE11, event is not firing in javascript - Stack Overflow

programmeradmin1浏览0评论

Tried not working this is an patability issue Ie9 vs 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 patibility issue in IE11. I placed a breakpoint in the readyStateChange() but its not triggering.

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

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

Tried not working this is an patability issue Ie9 vs 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 patibility issue in IE11. I placed a breakpoint in the readyStateChange() but its not triggering.

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

<iframe name="testwindowframe" id="testwindowframe" onreadystatechange="readyStateChange()" width="100%" height="90%"></iframe>
Share Improve this question edited Apr 10, 2015 at 2:10 asked Nov 10, 2014 at 0:04 user3082034user3082034 9
  • Well, <iframe> supports the event... Where is your readyStateChange() function declared? – Mr. Polywhirl Commented Nov 10, 2014 at 0:45
  • 2 "The following objects always fire the event because they load data: applet, Document, frame, frameSet, iframe, img, link, object, script, and xml elements.". See also: IE11 onreadystatechange event not firing. Basically: the onreadystatechange event is not being adopted by W3C since ages! And the result: IE11 has finally dropped it" – Mr. Polywhirl Commented Nov 10, 2014 at 0:48
  • [Mr.Polywhirl] lease find the code for readyStatechange().script is in same jsp . – user3082034 Commented Nov 10, 2014 at 1:06
  • Is this function declared in the <head> element of your HTML document? Have you tried to place a breakpoint in that function or place a console.log("Calling readyStateChange()") print statement in the function to see if it was actually called? Paste your JSP file with the JavaScript in-tact and obfuscate any information on that page that does not deal with this question... – Mr. Polywhirl Commented Nov 10, 2014 at 1:13
  • Mr.Polywhirl please find the jsp . I put a breakpoint in the method but its not reaching. – user3082034 Commented Nov 10, 2014 at 1:38
 |  Show 4 more ments

2 Answers 2

Reset to default 5

The attributes and event associated with checking the ready-state changes for <iframe> have been discontinued by Internet Explorer 11.

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)." [4]

"The point is that the onreadystatechange event is not being adopted by W3C since ages! And the result: IE11 has finally dropped it!" [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. [5]

Example

This code following code works in IE11, it will produce an alert when the <iframe> is loading.

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

Sources

Documentation

  • Internet Explorer Dev Center: [API Reference] readystatechange | onreadystatechange event 1

  • WebPlatform: readystatechange 2

Forum Questions

  • Internet Explorer Dev Center: [Community] IE11 onreadystatechange event not firing 3

  • Developer-Works.: IE11 onreadystatechange event not firing 4

Stack Questions

  • Access iframe elements in javascript 5

Try writing the function readyStateChange() in document.ready

发布评论

评论列表(0)

  1. 暂无评论