Hi,
I have a button that triggers (connected to) a Lightbox but I ALSO want that button to redirect to an external link 2 seconds after clicked (so the button has two actions basically, pop-up then redirect). It's already connected to the Lightbox, I just need the code for redirection after 2 seconds.
I am totally new to Wix but I can get to the dev code ( Please see attached) and the button id is #button3
Thank you.
Unlink the button to the lightbox. Create an onClick event for the button using the properties panel.
Your page code will look like this:
import wixWindow from 'wix-window'; export function button1_click(event) { let data = { url: 'https://www.google.com' //url to redirect to }; wixWindow.openLightbox('lightboxName', data); //open lightbox using name }
After this, remove the trigger from your lightbox and use the following code inside the lighbox.
import wixLocation from 'wix-location'; import wixWindow from 'wix-window'; $w.onReady(function () { let pmtdata = wixWindow.lightbox.getContext(); if(pmtdata) { setTimeout( () => { wixLocation.to(`${pmtdata.url}`); }, 2000); //2000 milliseconds } });