I need some help appending a modal from an iFrame to it's parent body. I've heard about the jQuery plugin SimpleModal and even tried it, but failed.
So I have a page with an iFrame and inside this iFrame there is a button that should open a modal window in the parent window. The problem is that I don't have access to put code into the parent window. I just have access to the iFrame.
For any kind of help, I'm very thankful!
Without any example code, it's kinda hard to show you per your exact layout, but I can give you an example of how I've achieved this. Keep in mind, everything must be on the same domain, which I would assume it is.
I had to do this for a CRM I've developed and here's an example of how I did it:
<body>
<div id="myModal">stuff</div>
<script>
$(function() {
$('#myModal').someDialogPlug({ some: options });
})
</script>
<button id="btnPopModal">click me</button>
<script>
$(function() {
$('#btnPopModal').on('click', function(e) {
// here's the fun part, pay attention!
var $body = $(window.frameElement).parents('body'),
dlg = $body.find('#myModal');
dlg.someDialogPlugin('open');
});
})
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With