Mobile page redirect

How do I redirect only my mobile version of the page to another website?

Hi,
You can check if a site visitor views the mobile site version using the formFactor function and use the to( ) function accordingly.

Best,
Tal.

Hello, I’m trying to redirect mobile users to a specific page when they open homepage of my website.
I have inserted following code to my site:

import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(funtion () {
      if(wixWindow.formFactor === "Mobile"){
            wixLocation.to('https://www.mywebsiteurl.com/mobile-page-name');
      }
});

Redirect works, but it works only after first loading the original homepage. I would like users to be directed to my mobile page immediately after they click on my site url without loading the homepage first.
Thank you.