Detect Apple Devices (iPad, iPhone, iPod) using jQuery
Related Post:
$(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. } });?
You can test this code by changing the user agent in your browser and set it to iPhone, iPad or iPod. There are many plugins/ extension available that allows to change User agent. Below is the link for various user agent switchers available with chrome and firefox.
If you just want to detect whether the device used is one of out of these 3 then you can create a function which will return true, if the devices is one of them otherwise false.
function isAppleDevice(){ return ( (navigator.userAgent.toLowerCase().indexOf("ipad") > -1) || (navigator.userAgent.toLowerCase().indexOf("iphone") > -1) || (navigator.userAgent.toLowerCase().indexOf("ipod") > -1) ); }
Feel free to contact me for any help related to jQuery, I will gladly help you.