Hi All,
I currently have a YouTube video embedded in my Wix site (once I get the original video I’ll upload the full file). I need an external url to launch when the video ends. At present I have code that launches the url after 49 seconds (length of the video).
However, given the browser restrictions on mobile it must be manually played. If it’s not played quick enough then the redirect to external url happens much sooner (I’m assuming 49 seconds after the page loads).
Any advice on what script to use? Currently I use:
import wixLocation from ‘wix-location’;
$w.onReady(initFunction)( function () {
setTimeout(() => {
wixLocation.to(“https://www.schweigen.com.au/appliances/wallmount/schweigen-silent-rangehood-wallmount-900mm”);
}, 49000);
});
Thank you.
Hi,
In the Youtube embedded element Properties panel, you can find function called ( onEnded ). All you have to do is to add the wixLocation inside the onEnded function - without setTimeOut .

export function videoPlayer1_ended(event) {
wixLocation.to("https://www.schweigen.com.au/appliances/wallmount/schweigen-silent-rangehood-wallmount-900mm");
}
Best,
Mustafa
Thanks so much Mustafa.
I removed all other code and placed this code, and it doesn’t seem to launch the URL at the end of the video. It just plays the video and stops. What do you think I’m doing wrong?
export function videoPlayer1_ended(event) {
wixLocation.to(“https://www.schweigen.com.au/appliances/wallmount/schweigen-silent-rangehood-wallmount-900mm”);
}
Euan
Hi Mustafa, thanks for this helpful hint. For the life of me I can’t get it to work though. Does the video behaviour properties have to be set to something specific?
This is the page I am attempting on and have entered this code for a desktop and mobile vidbox version (hidden on desktop)
www.beyonddesignagency .com (home page)
export function videoBox2_ended(event) {wixLocation.to("https://www.beyonddesignagency. com/creative-services");
}
export function videoBox1_ended(event) {wixLocation.to("https://www. beyonddesignagency. com/creative-services");
}
Did you already opened your own post, describing your issue completely in detail?
If not, do it and do not bump up old post!
If already done link it.