cjackson111
01-18-2012, 10:15 PM
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!
nomanic
01-18-2012, 11:16 PM
might be better doing this with php
felgall
01-19-2012, 01:35 AM
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.
Apostropartheid
01-19-2012, 12:31 PM
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?
kallejillheden
07-16-2012, 10:03 PM
If you download this file (http://php-mobile-detect.googlecode.com/files/php-mobile-detect.v.2.0.9.zip) 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
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect();
if($detect->isMobile() or $detect->isTablet()){
header("Location: http://m.yoursite.com/");
}
The script is not hard or complicated, if you reed it you would probably understand it clearly.
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 (http://code.google.com/p/php-mobile-detect/).
Important notes:
The file needs to be unzipped, and the content is going into your server.
The demo.php file is not necessary, only the Mobile_Detect.php file.
The Mobile_Detect.php file needs to be in the same directory as the file you put the script into.
waxdoc
07-16-2012, 11:28 PM
Think CSStricks.com featured this <script>
<meta name="viewport" content="width=device-width, user-scalable=yes">
<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "indexmobile.html";
}
//-->
</script>
Question being: "Does mobile device support JavaScript?"
Could add <nosript>If NO JavaScript, see indexmobile.httml</noscript>
May be clunky, but works.
StevenHu
12-12-2012, 10:18 PM
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!
Some people use this to detect the kind of mobile phone is in use, and redirect to a different site:
http://wurfl.sourceforge.net/index.php