JS Redirection – IOS – Android

Create in the same folder:
– mobile-detector.html
It this the javascript that detects the device type
– ios.html
The page for IOS devices
– android.html
The page for Android devices
– error.html
An Error page

mobile-detector.html


<!DOCTYPE html>
<html>
<head>
 
<script type="text/javascript">
// #######################################################
// Mobile JS Redirect
// Don't Break My b***s - Gimme Code! Project                                           
// Author: Andrea Tonin - http://blog.lucedigitale.com                                 
// This code come with absolutely no warranty                                            
// If you use this code in your project please give a link to http://blog.lucedigitale.com 
// Thanks in advance                                                                       
// #######################################################
 
var isMobile = {
        Android: function() {
            return navigator.userAgent.match(/Android/i);
        },
        BlackBerry: function() {
            return navigator.userAgent.match(/BlackBerry/i);
        },
        iOS: function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
        },
        Opera: function() {
            return navigator.userAgent.match(/Opera Mini/i);
        },
        Windows: function() {
            return navigator.userAgent.match(/IEMobile/i);
        },
        any: function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
        }

    };



if ( isMobile.Android() ) {
        document.location.href = "android.html";
    }
else if(isMobile.iOS())
	{
	document.location.href="ios.html";
	}
else
    {
    document.location.href="error.html";
    }
 
</script>
 
</head>
 
<body>
<center>
<br>
<b><h1>You are being redirected to other site.</h1>
<br>
<br>
<h1>If you are not redirected within 4 seconds</h1></b>
<br>
<h1><a href="android.html">ANDROID HERE</h1></a>
<h1><a href="ios.html">IOS HERE</h1></a>
</center>
</body>
 
</html>

ios.html


<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body>
<!-- Questo è un commento, non viene renderizzato dal browser -->
<h1>IOS!</h1>
</body>
 
</html>

android.html


<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body>
<!-- Questo è un commento, non viene renderizzato dal browser -->
<h1>Android!</h1>
</body>
 
</html>

error.html


<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body>
<!-- Questo è un commento, non viene renderizzato dal browser -->
You need an Android or IOS device!
</body>
 
</html>