Lightbox close button with code not working

I have the strangest “bug”:
I have a function that opens a lightbox and within that lightbox a link is showed to open another website in a new tab.
This new website can also be opened with a button from within the lightbox.
If I dont click this link I can close the lightbox with a button with velo-code - no problem.

But when I check the link and a new tab opens - the lightbox in the old tab can not be closed anymore.
This happens in all browsers.

The whole code on the close-button is not even called once the new tab was opened.

Anybody any ideas?
Thanks!

Can you supply the code to help me know what could be happening?

Hello Jarod, Thanks for asking!
This is the function that creates the link:

export function getLink ( messageIndex ) {
let beginLinkStringIndex = messages [ messageIndex ]. body . indexOf ( “<a” );
let endLinkStringIndex = messages [ messageIndex ]. body . indexOf ( “” );
let myLink ;

$w ( "#buttonLink" ). show (); 
myLink  =   messages [ messageIndex ]. body . substring ( beginLinkStringIndex ,  endLinkStringIndex + 8 ); 
$w ( "#textInhalt" ). html  =  messages [ messageIndex ]. body . replace ( myLink ,  "<u>Klicke hier und trage Deine möglichen Unterrichtstermine ein</u>" ); 
**let**  beginLinkIndex  =  myLink . indexOf ( "<u><a href='" )+ 12 ; 
**let**  endLinkIndex  =  myLink . indexOf ( "'>Klicke " ); 
myLink  =  myLink . substring ( beginLinkIndex ,  endLinkIndex ); 
myLink  =  myLink . replace ( "https" ,  "http" ); 
$w ( "#buttonLink" ). link  =  myLink ; 
//$w("#buttonLink").link = "http://www.stefanmens.ch"; 
$w ( "#buttonLink" ). target  =  "_blank" ; 

}

There is a button called “buttonLink” and this button has NO handler on it. It works with the above code.

And this is the call for closing the lightbox:
export function buttonNo_click ( event ) {
wixWindow . lightbox . close ();
}
It works fine until the “buttonLink” is clicked.

What do you think?

This may not be the problem but I have had this happen before. Are you using the button that was on the Lightbox template? The button on the templates are used to close the lightbox and if you try to connect code to it sometimes it acts in a weird way. I would try to delete the button, add your own, and then just rename the new button to buttonLink.

Thanks Jarod!
Actually I could solve it the other way round:
I indeed had my own button in the lightbox with wixWindow . lightbox . close (); code.
I deleted it and chose a close button from the lightbox set triggers. And now it works. Let’s see how long…

But thanks for your idea! It did the trick!