开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜