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.
Hey
I think you must do this inside a router to make it work as you want. Create a router and add:
import {redirect} from 'wix-router'; import wixWindow from 'wix-window'; export function myRouter_Router(request) { if(wixWindow.formFactor === "Mobile"){ return redirect("https://www.mywebsiteurl.com/mobile-page-name", "301"); } }
Read Wix Article on how to create routers:
https://support.wix.com/en/article/creating-a-router
Does anyone knows if it's possible to redirect to a dynamic page using a Wix tag in the URL?
I have 'projects' pages linked to a database, which are named '/project/{DB-title}' and what I'd like to do is redirect them when on mobile to '/project/b/{DB-title}'. But it does not interpret the {} as a tag, but as plain URL text...
I just posted this exact question - I didn’t see this thread first! I’m new to all this, so I might not have the right vocabulary yet.
But I believe there is a way to do a media query in CSS (if I’m saying that correctly) where you can do @media (hover : none) - which essentially targets all devices that don’t have a pointer or can’t hover.
But I’m not sure if something like that could be used in a Wix page.
I’d love to get a solid answer on how to send mobile devices to a specific page in my site.
Have any of you been able to get this to work, this is the exact same thing that I want to do. When some one is on a 980 wide resolution I want to push them to the mobile version of my site.
Having difficulty to set this up. I need a router that will replace my homepage with a mobile page instead.
Not quite sure I understand how this will work though as the router requires a prefix.
So what I need is that if someone accessed my site on mysite.com, if they are using a mobile device, it should redirect the request to mysite.com/mobilehome.
How do I need to modify the above code to make this work? Also is there a better way of doing this?
Many thanks
Thanks Andreas, I will read about Routers. Should I leave sitemap() function empty?