Supressing Script Error in IE8 (C++)
I want to prevent IE from showing JS error dialogs, I read that it can be done by setting ScriptErrorsSuppressed = true.
Where exactly do I set it in IWebBrowser2?
The docs you are reading refer to what you can do if you embed an IE HTML rendering pane in your own application. They allow you to alter the behavior of that pane.
If you have done that, then you can use COM to QueryInterface an IWebBrowser2 interface from the component.
See more here:
And here's how you handle errors:
I suspect that that's not what you are trying to do, and that you are just making a web-app. In that case, you need to
- Fix your JS errors
- Put all of your JS code in try/catch blocks. Then you won't get JS dialogs, but you need to handle the error yourself.
Simply use put_Silent method.
make change in both HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE paths.
Software\\Microsoft\\Internet Explorer\\Main RegSetValueEx (hKey, LPCSTR("Disable Script Debugger"), 0, REG_SZ, (BYTE*) "yes", 3); RegSetValueEx (hKey, LPCSTR("DisableScriptDebuggerIE"), 0, REG_SZ, (BYTE*) "yes", 3);
As mentioned earlier, use the put_Silent() method to turn error reporting on or off.
For example, if using a CDHtmlDialog, put this in your OnInitDialog():
and put it before the LoadFromResource() call.
The quick and easy way would be to use a global state to solve a local problem and modify the registry as described here (although Raymond would disapprove of doing so). This basically deactivates script errors entirely for the currently logged in user.
- Registry Key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
- Value Name: Disable Script Debugger
- Data Type: REG_SZ (String Value)
- Value Data: yes