Redirect page after a time delay

Hello guys!

In my website I have a welcome page and wanted to do something like the “welcome page” on the mobile site function.

So, what I did is to create a landing page with a welcome message and would like to redirect this to another page (URL) after a time delay of 2 seconds or whatever…

I looked up on internet for some javascript code and nothing works…

If the code can work on mobile and desktop, it would be great! So I can have the same for mobile and desktop.

Thank you guys! :slight_smile:

I appreciate your help!!!

This is the code I found on the forum and doesn’t work for me ar the moment:


import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(() => {
setTimeout(()=>{
if(wixWindow.formFactor === 'Mobile'){
wixLocation.to('https://www.mysite.com’) 
} else {
wixLocation.to('https://www.mysite.com') 
}
} , 5000)
})

Finally,

Here’s a working code to redirect after a time delay:


import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;
$w.onReady( function () {

setTimeout( function () {
wixLocation.to(‘https://www.yoursite.com’);
}, 2500);
});

Old post reappearing, closed

Already provided solution by Wix here.
https://support.wix.com/en/article/adding-a-welcome-screen-to-your-mobile-site

And here too.
https://support.wix.com/en/article/corvid-tutorial-redirecting-mobile-visitors

import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {

setTimeout(function () {

if(wixWindow.formFactor === "Mobile"){      wixLocation.to('http://www.myMobileHome.com');
}
}, 7500);

});