Popup opens when clicking on link and redirects

Hey, I want to inform my users via a popup notice that they’ll be forwarded to an external site when they click on an external link:

  1. User clicks on external link

  2. Popup (e.g. lightbox) opens

  3. redirect to external website (address of external link)

I have found the following code, but its not working:

import wixLocation from 'wix-location';

export function hoverBox2_click(event, $w) {
     $w('#hoverBox1').hide("fade",500);
     setTimeout(function () {wixLocation.to("/test"),500});
} 

instead of “/test” there must be automatically the address of the external link.

Would appreciate any help.

Thanks in advance!

Hi @alexander.lehmann1991

  1. Pop-up Opened But Link user not redirecting to new Page ?

  2. Pop-up Only Not Working.

  3. What code you have written to Open Pop-up

  4. and Where you written code for Pop-up OnClick [Button] ?

  5. Or, It redirects without show pop-up ?

Can you please give more clarity on the issue you are facing ?

The Pop-Up doesn’t open and the user redirects directly to the external page.

The code is written in my first post. So, there is no code for opening the popup I guess?

So,When Clicking On Button User Redirects to that Page Without Open Popup;

  1. Unlink that Button.


2. Then Write Below code On Click of that Button

export function button1_click_1(event) {
// Add your code for this event here:
import wixWindow from ‘wix-window’ ;

wixWindow . openLightbox ( “LightboxName” );
setTimeout ( function () {

wixLocation.to(“/test”)

}, 5000 );

}

You can adjust the Delay time once you see the Full result

Thanks for your help so far. I have a list of links in a textbox. The following code opens the particular link in a new tab and the lightbox appears.
So far, I added the following code:

import wixLocation from ‘wix-location’ ;
import wixWindow from ‘wix-window’ ;

export function text12_click(event) {
// Add your code for this event here:

wixWindow.openLightbox( "#welcomebox" ); 

setTimeout( **function**  () { 

},  5000 ); 

}

What I want is the active confirmation of a user via a submit button in the lightbox (“Do you want to get redirected to a external page - YES”) and then get the redirect in a new tab. Do you have an idea how this works?

@alexanderlehmann1991 check here https://www.wix.com/corvid/reference/$w/button/target

@ajithkrr I don’t think “target” helps since the link already opens in a new tab. Or am I missing something?