Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  14] [ 5]  / answers: 1 / hits: 38120  / 12 Years ago, thu, march 29, 2012, 12:00:00

I can check for iPhone with this code:



(navigator.userAgent.match(/iPhone/i))


But I want to target Windows Phone with this userAgent:



Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; 
Motorola_ES405B_19103; Windows Phone 6.5.3.5)


Is there any way to do this?


More From » user-agent

 Answers
9

Windows Phone certainly seems to be the term you want to match. So just exchange iPhone in your matcher with that term and you're good to go!






As mentioned in the comments: looking also for iemobile will give you an even broader range of detected microsoft mobiles OSes.



e.g.:



if(navigator.userAgent.match(/Windows Phone/i)){
alert('Is a windows phone!');
}

if(navigator.userAgent.match(/iemobile/i)){
alert('Is some mobile IE browser!')
}

// and probably less common, but still useful:
if(navigator.userAgent.match(/WPDesktop/i)){
alert('It is a windows phone in desktop mode!')
}

[#86536] Wednesday, March 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylee

Total Points: 60
Total Questions: 119
Total Answers: 101

Location: Bonaire
Member since Wed, Mar 29, 2023
1 Year ago
;