Richard Knop
Richard Knop

Reputation: 83697

How to close an iframe from inside that iframe

I have a an iframe with content from another PHP page on my server inside a modal window. I would like to figure out a way how to close the modal box with the iframe from inside the iframe.

I am using this modal window plugin: http://opensource.steffenhollstein.de/templates/modalbox/

According to the documentation this method closes the modal window:

jQuery.fn.modalBox.close();

If I put it inside the iframe like this:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.modalbox-1.0.9/js/jquery.modalbox-1.0.9-min.js"></script>
<script type="text/javascript">
    //<!--
$(document).ready(function() {

    $('.closeModalBox').click(function() {
        jQuery.fn.modalBox.close();
    });

});    //-->
</script>

I have an input with the class .closeModalBox in the iframe:

<input type="submit" name="zrusPridatElearningKurz" id="zrusPridatElearningKurz" value="Storno" class="input-submit closeModalBox" />

Upvotes: 1

Views: 868

Answers (1)

devmake
devmake

Reputation: 5262

Try window.parent.jQuery.fn.modalBox.close(); I have used this approach with a different popup component, but it could help...

Upvotes: 1

Related Questions