-1

I'm making a webpage in PHP and I want to show a user different contents when he accesses the page in IE desktop mode and IE modern UI mode on Windows 8.

Can user-agent do this? If not, are there any possible solutions? Thank you.

ChandlerQ
  • 1,428
  • 2
  • 21
  • 29
  • 1
    Unfortunately there is no way to sniff modern UI IE through the `User-Agent` header. – Jon Aug 26 '13 at 15:20
  • @Jon so are there any other solutions apart from `User-Agent`? Or we just simply can't do this? – ChandlerQ Aug 26 '13 at 15:41
  • AFAIK you can't do this. Why you want to do it is also something to think about -- perhaps there's a better way to your goal? – Jon Aug 26 '13 at 15:43
  • @Jon I have two versions of an application, one is an Win8 modern app and the other is a classic desktop application. Visitors may want to download Win8 modern app if they access this page from a modern-mode browser and they may just want the desktop version if they view the webpage in a classic desktop browser program. I need to know if my visitors are come from a modern browser app in order to provide them with different download links. – ChandlerQ Aug 26 '13 at 16:33
  • @AmareKnight: In that case a JS solution from the linked dupe question should do fine. As long as you also offer an unobtrusive "other platforms" link somewhere so that the end user can override your detection you should be in great shape. – Jon Aug 26 '13 at 17:25

1 Answers1

-2

Check with Javascript if ActiveX enabled (Metro doesn't allow any activex content, but desktop IE can )

function isActivexEnabled() {
    var supported = null;        
    try {
        supported = !!new ActiveXObject("htmlfile");
    } catch (e) {
        supported = false;
    }

    return supported;
}

and send that information to PHP script through Ajax for example

Jacklapott
  • 65
  • 1
  • 7
  • 1
    There is a [much more comprehensive question](http://stackoverflow.com/questions/8751479/javascript-detect-metro-ui-version-of-ie) that deals with JavaScript solutions (which are really off topic for this question), and the consensus there is that you cannot be *sure*. Desktop IE could also have ActiveX disabled. – Jon Aug 26 '13 at 15:58
  • As the previous comment said, a user can turnoff ActiveX for Desktop IE, so this is far from a bulletproof solution. – macguru2000 Dec 03 '14 at 23:52