I have a IWebBrowser2 I use to visit some webpages with .Navigate()
When the page has a js error I got a warning box for "Syntax error", so I used .put_Silent(TRUE). And now I get a warning for "VS Just-In-Time Debugger: Unhandled exception" instead
How can I disable all the script error warnings (including JIT debugger) from my code (i mean without modifying the real IE settings)?
You can disable script debugging by overriding the registry settings that control it. The correct way to do this is to implement the IDocHostUIHandler interface, and specifically the IDocHostUIHandler::GetOptionKeyPath or IDocHostUIHandler::GetOverrideKeyPath methods. Use GetOptionKeyPath to ignore all the user's IE settings (e.g., font size) and use IE defaults, or GetOverrideKeyPath to use most of the user's IE settings but override a few specific ones.
The MSDN articles linked above contain good documentation on how to use this interface, as well as sample implementations of the IDocHostUIHandler interface and its methods.
Say that your GetOptionKeyPath method returns "SOFTWARE\MyCompany\MyApp\IE"
as the new registry path. To ensure that script debugging is disabled, you would need to create the HKEY_CURRENT_USER\Software\MyCompany\MyApp\IE\Main
registry key, then create a string value named Disable Script Debugger
having the value yes
.