8

Is there any way that I could tell if my site is being accessed by an instance of webbrowser control? Would it be possible to identify it by the user agent w/php? Or maybe some javascript hack? Or is it 100% identical to the regular IE from the server side?

clami219
  • 2,958
  • 1
  • 31
  • 45
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
  • It _is_ IE. It's precisely the same code, as far as I know. – John Saunders Feb 04 '10 at 00:28
  • 1
    "Internet Explorer" is basically a thin UI around the web browser control. – Anon. Feb 04 '10 at 00:31
  • According to [this answer](https://stackoverflow.com/a/4357982/1009922) and to [this more recent article](https://blogs.msdn.microsoft.com/patricka/2015/01/12/controlling-webbrowser-control-compatibility/), the WebBrowser control shows `MSIE 7.0` in its user-agent string. I think that this is not distinguishable from an actual IE7 browser or a more recent IE browser in version 7 compatibility mode. – ConnorsFan Jul 18 '17 at 14:26

2 Answers2

4

It seems that a specific error is raised when anything is assigned to window.external. So a check could be something like

const isWebBrowserControl = () => {
  try {
    window.external = window.external
    return false
  } catch (error) {
    if (error.message === 'I don\'t remember this. Some specific error message.') {
      return true
  }
}

This is a potentially "destructive" check, though. But I really don't feel it would cause any problem.

Shahar 'Dawn' Or
  • 2,713
  • 1
  • 26
  • 38
3

Just a stupid idea, but couldn't you just compare window.outerHeight with window.innerHeight, measure the expected difference for IE and if its not then its the WebBrowser Control?

Thats hacky as hell, but could work for most cases. There are also other things you could try to do, things that would work in a certain way in IE but probably won't work in a WebBrowser Control.

For example:

  • download a file
  • open a new window/tab
Lux
  • 17,835
  • 5
  • 43
  • 73
  • I don't see how this can be reliable. The difference between `outerHeight` and `innerHeight` is affected by user preferences. Showing or hiding the bookmarks bar or the menu will affect the difference. (I counted 4 readily accessible options in IE that affect the difference.) Having the debug panel open or closed also affects it. Zoom also affects it. (I was not expecting that, but here we are.) Then there are things like general UI preferences. Using a theme different from the default may change the difference between the two numbers. – Louis Jul 20 '17 at 15:28