How to fix javascript error in application using IWebBrowser2?

烈酒焚心 提交于 2019-12-10 11:18:11

问题


I have a C++ aplication that is using the IWebBrowser2 interface for rendering some online html pages. The problem is that when accesing a certain link I receive a javascript error, although if I am accesing that same page using Internet Explorer, the page loads with no error. The recived error in my application is "Object doesn't support this action"

I was able to hide the error by using the put_Silent() method and setting it to VARIANT_TRUE, but this is not a solution as the content displayed is not correct.

I know that IWebBrowser2 is using the Internet Explorer engine to load the pages, so I guess that there is a way to fix this problem as the page loads ok in IE.


回答1:


You may have to implement IDocHostShowUI::ShowMessage.

When your application hosts the browser control, you can replace the Windows Internet Explorer message box caption (which is used for Microsoft JScript alerts among other things) with a custom caption

I think you would want to return S_FALSE.

S_FALSE Host did not display its UI. MSHTML displays its message box.



来源:https://stackoverflow.com/questions/12642479/how-to-fix-javascript-error-in-application-using-iwebbrowser2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!