![]() |
(http://www.codingforums.com/forumdisplay.php?f=70)
...if viewed on a mobile phone
Hello. I am not sure if this is the correct place for this question. Please direct me if not. I am trying to set a webpage to redirect and display a different page if the first page is accessed from a mobile device (phone). Does anyone know how I can achieve this? I just need to know how to determine what it is viewed on. The redirect part I know already.
Thanks so much for all help! |
might be better doing this with php
|
The simplest way would be to test the viewport width and redirect if the width is less than whatever you decide is the widest that you want to redirect.
|
Although generally you shouldn't redirect, because you have to deal with two versions of your site; have you considered simply styling the page differently?
|
If you download this file and put it into your site and then put this into your index.php file:
It needs to end with .php or else the script won't work PHP Code:
This will redirect any mobiles or tablets to your mobile version of your site. More info on how you can use the Mobile_Detect.php file can be found here. Important notes: The file needs to be unzipped, and the content is going into your server. |
JS to refirect
Think CSStricks.com featured this <script>
Code:
<meta name="viewport" content="width=device-width, user-scalable=yes">Could add <nosript>If NO JavaScript, see indexmobile.httml</noscript> May be clunky, but works. |
Quote:
http://wurfl.sourceforge.net/index.php |
| All times are GMT +1. The time now is 10:53 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.