1

I've had mobile device redirection for quite a while now, but something that's bugged me is that (to the best of my knowledge) Windows Phone users aren't being redirected.

My question is, How do I redirect Windows Phone users?

My Code:

<script>
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) )
{ window.location = "http://m.ctworkshop.us/"; }
</script>

Is it possible? What name would I add to do so, if it is?

Ps. adding "Windows" to that list redirects desktop Windows which I don't want to do.
Community
  • 1
  • 1
Chris
  • 69
  • 2
  • 9
  • 1
    Just out of curiosity, why not make the site responsive? – hopkins-matt Feb 19 '16 at 20:17
  • 2
    Possible duplicate? http://stackoverflow.com/questions/9926504/how-do-i-check-windows-phone-useragent-with-javascript – Dan Orlovsky Feb 19 '16 at 20:21
  • 1
    look for the string "Windows Phone" not just windows. here's a useragent string for windows phone: `Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)` – I wrestled a bear once. Feb 19 '16 at 20:24

1 Answers1

1

How about

navigator.userAgent.match(/Windows Phone/i)

Here's a blog post from a Microsoft employee about correctly detecting Windows phones which uses the same strategy.

rphv
  • 5,409
  • 3
  • 29
  • 47
  • Sorry I never came back to this, totally forgot I asked the question. I think that'll work perfectly, and it was a simple fix of course....Thank you so much! – Chris Mar 10 '16 at 11:56