You can use Velo to redirect visitors to mobile-friendly pages in your site.
The basic steps to redirect to mobile pages are:
This tutorial has 2 parts:
The code checks the kind of device. If mobile, the code redirects the visitor to a mobile-friendly home page.
Import statements on lines 2 and 3 bring in the APIs we need:
wixWindowFrontend.formFactor checks the device type.wixLocationFrontend.to redirects the visitor to the mobile page's URL.The redirect occurs after a time delay. This gives the visitor time to see notices on the page you are redirecting from. Line 4 contains the setTimeout function that creates this delay.
With an if statement on line 10, we check the type of device using wixWindowFrontend.formFactor.
On line 13, we use wixLocationFrontend.to to perform the redirect.
The following APIs are used in the code in this article. To learn more, see the API Reference.