I have a webpage not rendering properly on mobile and Apple devices, and I have made an alternate version for them. How can I, preferably with html only, make those devices load the alternate version when accessing the main one?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have access to the logic side of the site (php/javascript), you can implement a check to see if the User Agent string the browser sends in their request, contains “iPhone”, “iPad”, or “Android”. Next you can redirect to this other page by using the “Location” response header. For example:
JavaScript:
PHP:
I’d prefer the PHP solution:
the browser sends a request to the webserver. The webserver will see the user agent is a mobile device and redirect to the correct page.
As where the JavaScript solution will request the webpage, receive it, load the JavaScript and send a new request to the webserver. (I believe it happens like this, please correct me if I’m wrong)
Plus, as you have mentioned in the comments, not every user has their JavaScript enabled in their browser.