comments 2

Detect IE Mobile with jQuery

There are multiple ways to detect IE Mobile with jQuery. A few methods to detect windows phone internet explorer with jQuery / JavaScript are with fiddle demo;

Method 01

Fiddle

if(navigator.userAgent.match(/iemobile/i)) 
{                                       
    alert('IE Mobile Detected');
}

Method 02

Fiddle

if (isIEMobile() === true) {
    alert('IE Mobile Detected');
}

function isIEMobile() {
    var regExp = new RegExp("IEMobile", "i");
    return navigator.userAgent.match(regExp);
}

Mobile Specific

Nokia Lumia or any Windows Phone browser has desktop and mobile browsing mode, IEMobile sends different user agent. Desktop mode does not send Windows Phone X.Y model argument. Find Windows+ARM+Touch+WPDesktop tags and possibly screen size to guess wphone or tablet.

Lumia 920 WPhone 8, Desktop mode
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; ARM; Touch; WPDesktop)

Lumia 920 Windows Phone 8
Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)

Lumia 820 Windows Phone 8
Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 820)

Lumia 800 Windows Phone 7.5
Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 800)

Lumia 900
Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 900)

WP7.5 IEMobile9 desktop mode
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; XBLWP7; ZuneWP7)

  • This entire post was plagiarized from StackOverflow (and ironically the solution above fails for many of the example user agents in this post).

    • Aamir Shahzad

      Thanks @BenSwayne:disqus for mentioning it but if you look closely at stackoverflow it was answered by me in some post. When I don’t have much to share I use my stackoverflow answers here but usually not cut/paste.

      Mobile specific part is not a property of stackoverflow.com its available on w3schools.com and lots of other blogs. If you share me what’s wrong and what fails I will fix it and also report to w3schools & stackoverflow. They will be thankful.