如何使用IWebBrowser2修复应用程序中的javascript错误? [英] How to fix javascript error in application using IWebBrowser2?

查看:305
本文介绍了如何使用IWebBrowser2修复应用程序中的javascript错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++应用程序,它使用IWebBrowser2接口呈现一些在线html页面. 问题是,当访问某个链接时,我会收到一个JavaScript错误,尽管如果我使用Internet Explorer访问同一页面,则该页面加载不会出现任何错误. 我的应用程序中收到的错误是对象不支持此操作"

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"

我能够通过使用put_Silent()方法并将其设置为VARIANT_TRUE来隐藏错误,但这不是解决方案,因为显示的内容不正确.

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.

我知道IWebBrowser2正在使用Internet Explorer引擎加载页面,所以我猜有一种方法可以解决此问题,因为该页面在IE中可以正常加载.

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.

推荐答案

您可能必须实现

当您的应用托管浏览器控件时,您可以替换 Windows Internet Explorer消息框标题(用于 带有自定义标题的Microsoft JScript警报等

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

我认为您想返回S_FALSE.

I think you would want to return S_FALSE.

S_FALSE主机未显示其UI. MSHTML显示其消息框.

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

这篇关于如何使用IWebBrowser2修复应用程序中的javascript错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆