Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect WebBrowser Control

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?

like image 584
Ilia Choly Avatar asked Feb 04 '10 00:02

Ilia Choly


2 Answers

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.

like image 87
mightyiam Avatar answered Sep 19 '22 13:09

mightyiam


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
like image 23
Lux Avatar answered Sep 22 '22 13:09

Lux