Detect iPad and iPhone in web browsers

In this short post, I will share a web page redirection code for users of iPad, iPhone or ipod who have no access to Adobe Flash media.

In the first week of November 2011, Adobe announced that it will cease developing its Flash Player plug-in for mobile browsers. The next most affected devices(besides the iPad, iPod, iPhone) are those based on Android OS.

Below is simple javascript that needs to be inserted into the top section of your web page (between the and tags) to re-direct those users to an alternative page.

<!--ipad redirect-->
<script language=javascript>
if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)
|| (navigator.userAgent.indexOf('iPad') != -1)) {
document.location = "";

In this example, /directory/ is optional (in case that your site or iPad friedly version of your site resides in another directory) and index1.html is an alternative index.html that does not contain any Flash code. Index1.html is essentially a copy of the index.html where the Flash part is replaced with JQuery or html5 code to display the original slides or movie. It is where the visitor will be re-directed to.

No Responses — Written on October 9, 2011 — Filed in: Code

Leave a Reply

Your address will not be published.