How to Detect Android and Redirect to Android Version Website

android-phone

I have been posting redirect scripts for several devices such as the iphone and ipad, and I thought why not add android to the list. I own a android phone and I love it, and I have tested this script so I know it works. This code detects whether the person viewing your website is on a Android device. If they are on a Android phone, you can redirect them to a android version website or just to another page, its up to you. If they are on a normal computer it doesn’t redirect them and they go on as normal. Its just some simple javascript, and if you want to use it just change the “document.location” value to the url you want them redirected. Here is the code, and its just the same as when you detect for iPhone.

1
2
3
4
5
<script type="text/javascript"> // <![CDATA[
	if ( (navigator.userAgent.indexOf('Android') != -1) ) {
		document.location = "http://www.yoururladdress.com/yourpage.html";
	} // ]]>
</script>

Cya

How to Detect iPad and Redirect to iPad Version Website

With all the buzz about the iPad, I wanted to post another useful snippet of code. It detects whether the person viewing your website is on a iPad. If they are on a iPad, you can redirect them to a iPad version website or just to another page, its up to you. If they are on a normal computer it doesn’t redirect them and they go on as normal. Its just some simple javascript, and if you want to use it just change the “document.location” value to the url you want them redirected. Here is the code, and its just the same as when you detect for the iPhone with an extra argument.

1
2
3
4
5
<script type="text/javascript"> // <![CDATA[
	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
		document.location = "http://www.scottrockers.com/iphone.html";
	} // ]]>
</script>

Cya