Execute a javascript function on the second load of an iframe
Is there a way to execute a javascript function on the second load of an iframe? Right now I am nesting two addEventList开发者_运维技巧eners:
document.getElementById('my_iframe').addEventListener("load", function() {
document.getElementById('my_iframe').addEventListener("load", doSomething(), true);
}, true);
The first "load" is triggered when I use document.my_iframe.write('...'). I want to trigger an action after I submit a form in the iframe, which is the second "load".
Is there a better way to accomplish my goal?
The event will fire each time the iframe is loaded no need for nesting, just for a counter.
var count;
element.addEventListener("load", function() {
count++;
if(count==2){
//code goes here
}
}, true);
精彩评论