View Full Version : Detect Mobile Platform

09-25-2011, 05:20 AM
Hi, i have from in detecting mobile platform. This is i use to redirect the home page, to the mobile version.

I'm using this script now:

<script type="text/javascript">
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
document.location = "mobile.html";

This is my website then i'm try to implement (http://www.ninetynine.co.id)

But not it failed. So is there any other script to help me...
Thanks in advanced.

09-25-2011, 08:08 AM
I have no mobile device to test on. Which are you using? What's its navigator.userAgent string look like? Does it contain any of the keywords that the regular expression tests for? To find out, use a simple page:

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">

A simulator might not report the the navigator.userAgent. Although it should, all it's technically required to do is to render as that agent. To find out, again one can run the simple test page above.

Anyways, try this:

<script type="text/javascript">
if (/android|blackberry|iphone|ipod|mini|palm|series60|symbian|windows ce/i.test(navigator.userAgent)){
location.href = "mobile.html";

Oh, and what does this:

i have from in detecting mobile platform


09-26-2011, 02:16 AM
Thanks John, i'll try it.