Chris
Chris

Reputation: 69

How do I redirect windows phones (but not desktop windows) to a mobile site using html?

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.

Upvotes: 1

Views: 122

Answers (1)

rphv
rphv

Reputation: 5537

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.

Upvotes: 1

Related Questions