Detect WebBrowser Control
Is there any way that I could tell if my site is being accessed by an instance of webb开发者_如何学运维rowser 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?
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.
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
精彩评论