How to Detect & Redirect an iPad

Written by john mitchell Google
  • Share
  • Tweet
  • Share
  • Email

When you want to redirect a site visitor to an iPad-friendly version, you will need to use a small JavaScript code snippet to detect the computer's user agent setting. Most computers and devices, including the iPad and iPhone, send the user agent data to the website they are accessing. This is helpful for detection and redirection purposes.

Skill level:
Moderate

Other People Are Reading

Instructions

  1. 1

    Open the main HTML page to your website in a text editor.

  2. 2

    Locate the <head> and </head> tags, usually at the top of the document.

  3. 3

    Insert this JavaScript code before the </head> tag:

    <script type="text/JavaScript">

    var ua = navigator.userAgent;

    var checker = {

    iOS: ua.match(/(iPhone|iPod|iPad)/) };

    if (checker.iOS) { window.location = "http://example.com/ipad.html;

    };

    </script

  4. 4

    Replace the "example.com" domain name with your site's domain address.

  5. 5

    Save the HTML file and upload it to your Web hosting server.

Tips and warnings

  • You will need to create an iPad-friendly Web page to redirect the visitor from the main website.
  • Before implementing this redirect code, thoroughly test your iPad version for your website for usability and performance. If you insert this code prematurely, then you may end up redirecting the visitor to a page that does not exist.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.