Moak
Moak

Reputation: 12885

Redirect IE7 browser BUT NOT windows phone 7

I am not able to debug and test windows 7 phone, however I have following code

<!--[if lte IE 7]><meta http-equiv="refresh" content="0; url=/index_ie.html" /><script type="text/javascript"><![CDATA[ window.top.location = "/index_ie.html";]]></script><![endif]-->

However I just heard from a friend that this is affecting his windows mobile phone, which has this agent:

Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0)

Is there a way to exclude windows mobile browser from triggering this redirect?

Upvotes: 1

Views: 230

Answers (1)

Armatus
Armatus

Reputation: 2191

His Windows phone has IE Mobile 7, so it makes sense that a lte IE7 evaluates to true and triggers the redirect. You could try this:

<!--[if !IEMobile]>
<![if lte IE 7]>      
...
<![endif]>
<![endif]-->

See here for more ideas: Conditional Comments to target Windows Phone 7 Internet Explorer 9 and Is there a way to target Windows Mobile 7.5 browser using conditional comments?

Upvotes: 2

Related Questions