{"id":161,"date":"2012-02-04T02:48:39","date_gmt":"2012-02-04T02:48:39","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=161"},"modified":"2012-02-04T02:48:39","modified_gmt":"2012-02-04T02:48:39","slug":"javascript-detect-iphone-ipod-ipad","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/javascript-detect-iphone-ipod-ipad\/","title":{"rendered":"Javascript: Detect iPhone, iPod, iPad"},"content":{"rendered":"<p>Have ever ever thought of display custom information to the user or making changes in the browser depending upon whether the user is using iPhone, iPod or iPad?\u00a0Here is a snippet in Javascript: Detect iPhone, iPod, iPad using this handy snippet!<!--more--><\/p>\n<h2>How to Detect iPhone, iPod, iPad using JavaScript &#8211; Examples<\/h2>\n<p>Insert the following snippet just above your &lt;\/head&gt; tag:<\/p>\n<pre class=\"lang:js decode:true\">&lt;script type=\"text\/javascript\"&gt;\n\/\/Make your JS compatible by using the following tags\n\/\/&lt;![CDATA[\n\n\/\/ Apple detection object\nvar Apple = {};\nApple.UA = navigator.userAgent;\nApple.Device = false;\nApple.Types = [\"iPhone\", \"iPod\", \"iPad\"];\nfor (var d = 0; d &lt; Apple.Types.length; d++) {\nvar t = Apple.Types[d];\nApple[t] = !!Apple.UA.match(new RegExp(t, \"i\"));\nApple.Device = Apple.Device || Apple[t];\n}\n\/\/ is this an Apple device?\n\/*alert(\n\"Apple device? \" + Apple.Device +\n\"\\niPhone? \" + Apple.iPhone +\n\"\\niPod? \" + Apple.iPod +\n\"\\niPad? \" + Apple.iPad\n);*\/\nif ( true == Apple.iPhone )\n{\n \/\/do this\n}\nelse  if ( true == Apple.iPod )\n{\n\/\/do this\n}\nelse  if ( true == Apple.iPad )\n{\n\/\/do this\n}\n\n\/\/]]&gt;\n&lt;\/script&gt;<\/pre>\n<h5>That&#8217;s it!<\/h5>\n<p>Did you like this post?\u00a0Do you know of any other ways to <strong>detect iPhone, iPod, iPad using JavaScript<\/strong>? Feel free to suggest by commenting below.\u00a0We would love to hear from you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have ever ever thought of display custom information to the user or making changes in the browser depending upon whether the user is using iPhone, iPod or iPad?\u00a0Here is a snippet in Javascript: Detect iPhone, iPod, iPad using this handy snippet!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12,17,6,13],"tags":[34,35],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-javascript","category-javascript-tips-and-tricks","category-snippets","category-tips-and-tricks","tag-javascript-snippets","tag-javascript-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-2B","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=161"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/161\/revisions"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}