Skip to content

Instantly share code, notes, and snippets.

@nukecpower
Created June 25, 2013 17:27
Show Gist options
  • Save nukecpower/5860452 to your computer and use it in GitHub Desktop.
Save nukecpower/5860452 to your computer and use it in GitHub Desktop.
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)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment