How to detect IPhone / IPad through JavaScript

Posted by Anuraj on Wednesday, December 4, 2013

.Net ASP.Net Javascript

Here is code snippet which helps to identity IPhone or IPad through JavaScript.

if ((navigator.userAgent.match(/iPhone/i)) ||
    (navigator.userAgent.match(/iPad/i))) {
    //IPhone or IPad
}

And here is the C# snippet for user agent checking.

if (Request.UserAgent.IndexOf("iPhone", StringComparison.CurrentCultureIgnoreCase) >= 0 ||
    Request.UserAgent.IndexOf("iPad", StringComparison.CurrentCultureIgnoreCase) >= 0)
{
    //IPhone / IPad
}

Happy Programming :)



Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon



MVP
Subscribe


Copyright © 2017 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub