I am building a very basic html-only site to display a specifically-sized project that is really only meant to be viewed on a computer. I seem to only find information on how to make your site mobile-friendly, but I want the opposite. Is there a way to redirect mobile users to a completley separate page, or to not allow the site to be viewed from mobile at all?
A lot of the answers that I have seen involve javascript or jquery but I would like to avoid that if possible
2
Answers
just redirects if you are in anything other than a phone.
Without using javascript you can’t redirect to an other page when the user is in mobile. However you can change the display property in the body tag when a specific screen size is detected like this:
Or, if you need to redirect to another page, you have to use JavaScript:
Use this code in your page to redirect to another url (or page) if a mobile browser detected:
The
window.mobileCheck()
will check if the user is in a mobile browser. Then changing thewindows.location.href
will redirect to an other page. (Remember to replace that"mobile.html"
to the url/page you want to redirect.)