How to detect IPhone / IPad through JavaScript

Posted by Anuraj on Wednesday, December 4, 2013 Reading time :1 minute

.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 :)

What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.

Similar Posts

Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon

BMC logoBuy me a coffee

Copyright © 2019 - 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