nukecpower
6/25/2013 - 5:27 PM

Detect Apple Devices (iPad, iPhone, iPod) using jQuery

Detect Apple Devices (iPad, iPhone, iPod) using jQuery

$(document).ready(function(){
  var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone");
  var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad");
  var isiPod = navigator.userAgent.toLowerCase().indexOf("ipod");

  if(isiPhone > -1)
  {
      //Redirect to iPhone Version of the website.
  }
  if(isiPad > -1)
  {
      //Redirect to iPad Version of the website.
  }
  if(isiPod > -1)
  {
      //Redirect to iPod Version of the website.
  }    
});


function isAppleDevice(){
    return (
        (navigator.userAgent.toLowerCase().indexOf("ipad") > -1) ||
        (navigator.userAgent.toLowerCase().indexOf("iphone") > -1) ||
        (navigator.userAgent.toLowerCase().indexOf("ipod") > -1)
    );
}