How to close a lightbox from javascript

  • 19 July 2019
  • 2 replies
  • 102 views

This used to work:

top.lp.jQuery.ubpoverlay.close();

Suddenly it stopped working. Have also tried this:

javascript:lp.jQuery.ubpoverlay.close()

from here: https://gist.github.com/johnnyopao/54790aef1f81eb68a03a

which also doesn’t work.

I want to programatically close the lightbox which a page is showing on (from that page (which is embedded as an iframe)). The user gets to that lightbox content after clicking a CTA button which specified that a page should be opened in a lightbox.


2 replies

For anyone else, I solved it with this:

top.lp.jQuery('button[type=button][role=button]').click()

hacky but works.

Badge
$("#lp-pom-button-11").click(function(event){
  event.preventDefault();
  window.parent.$('button[type=button][role=button]').click();
}); 

Works for me.
Where lp-pom-button-11 is the button id in Lightbox.

Reply