2

I use featherlight to open a image upload/resize/cropping page via an iFrame.

I would like to call the closeTrigger as soon as the user hits save (within the iFrame) so that they don't need to close it manually

I'm a bit confused about this. I've checked the min.js but couldn't find anything, and I also didn't find the Javascript action tied to the closing button...

Any ideas?

Canelo Digital
  • 340
  • 2
  • 10

2 Answers2

3

This also works: parent.window.$.featherlight.current().close();

Vaibhav Garg
  • 3,630
  • 3
  • 33
  • 55
  • great short approach, I like it... thank you and sorry for the missing feedback.. nevertheless I prefer to mark the other answer as accepted because it offers more flexibility to do some pre- or post processing on the parent frame... – Canelo Digital Jan 09 '18 at 01:23
2

I found an answer here How do I remove iframe within itself by using javascript

iFrame (after eveything is done):

<script>parent.window.postMessage("closetheiframe", "*");</script>

ParentWindow:

<script>
function receiveMessage(event){
   if (event.data=="closetheiframe"){
  var current = $.featherlight.current();
 current.close();
   }
}
 window.addEventListener("message", receiveMessage, false);

theoretically, if featherlight.current works fine, this would help me also on a page, where I use different iFrames to be opened and closed (not at the same time though)

Community
  • 1
  • 1
Canelo Digital
  • 340
  • 2
  • 10