0

I am not sure if this is possible but I have a small web application that is responsible for uploading files to the server. This app is used by another app which includes it in an iFrame.

The uploader app is using jQuery form to submit the file in the background and I would like to be able to notify the parent app when the upload is complete and the success callback fires.

I was thinking about somehow passing a function into the iFrame app that could be called from the parent but I am not sure how to do this or if it is even possible.

3 Answers 3

1

If both apps are hosted on the same domain, accomplishing this is trivial.

To call a function in the parent window from the iframe:

parent.myFunction();

To call a function in the iframe from the parent window:

document.myFrameName.myFunction();

(This requires that the iframe have a name attribute set).

If the apps are on different domains, you'll have to perform some greater hackery to accomplish this.

Sign up to request clarification or add additional context in comments.

Comments

1

You can call parent.functionname. Or you can try the IFrame event, onLoad to call from the parent page itself.

Comments

0

I'm not sure what's the right way to do this, but you can write something like document.callback = function() { ... } in your parent frame and parent.document.callback() in your iframe.

Of course your pages in parent frame/iframe must be from the same domain or browser will block any interaction between them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.