iPad, iPhone detection & redirect

Here are two scripts that you can add to your websites index page to enable detection and redirection to alternative content if viewed on an iPhone, iPod or iPad. Handy if you have a flash site or if you just want to redirect users to alternative styled content. Just change the URL to the content you want to redirect to.

EG.1

<script type="text/javascript">
	if ( (navigator.userAgent.indexOf('iPad') != -1)) {
		document.location = "http://www.yourdomain.com/ipad";
	}
</script>

EG.2

<script type="text/javascript">
	if ((navigator.userAgent.indexOf('iPhone') != -1)
                ||(navigator.userAgent.indexOf('iPod') != -1)) {
		document.location = "http://www.yourdomain.com/iphone";
	}
</script>

Example 1. Detection of an ipad and redirects, Example 2. Detection of an iphone and ipod and redirects. You could have three detections and redirect to three different URLs, or have one detection for all and redirect to one URL.