Question

I'm tyring to trigger an event on window.parent on button click from an iframe using jquery with a timeout of 2 seconds

My in-iframe Button:

<input id = 'submit' type = "submit" name = 'submit' value = "Save">

The JQuery Event:

$("#submit").click(function(){
    window.parent.setTimeout(function(){
        // some stuff ....
    }, 2000);

});

Well, this is working with Safari 7.0.3 and Chrome 34.0.1847.116 m But in Firefox 28.0 and my current Version of IE11 i have no chance to get it working.

Does anyone know the trick?

Was it helpful?

Solution

First, are you ok with only allowing the newest browsers?

In that case you can use postMessage, one the click, you wait 2 seconds, then send a message telling the parent to trigger the event. This only works if you have control over both however.

Can scripts in iframe interact with scripts in the main page

This question above goes into more detail then I can above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top