iwebbrowser2 Javascript onQuit事件 [英] Iwebbrowser2 Javascript onQuit event

查看:61
本文介绍了iwebbrowser2 Javascript onQuit事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用嵌入式浏览器来显示具有富文本编辑器的特定网页.

该文本编辑器已将自身与某些事件挂钩,以检测浏览器何时尝试关闭/离开页面.编辑器将验证是否已保存最新更改,如果未保存,则会提示用户这样做.


如果在独立的Internet Explorer中打开页面,则导航(通过键入新的url)并关闭选项卡/窗口都将触发javascript.


当页面显示在嵌入式Iwebbrowser2控件中并且我们发送新的URL时,将正确触发javascript.但是我们无法关闭该事件.

当我们关闭控件所在的框架时,所有面板/控件都将被破坏.

如何以编程方式告诉Iwebbrowser2我们将要关闭?

当我收到框架的onCloseEvent时,我也尝试调用Quit函数.
到目前为止,调用Iwebbrowser2 :: Quit根本行不通.该函数始终返回e_fail.



我可以用wxactivex示例进行演示.
我已将其更改为默认打开此URL:http://www.4guysfromrolla.com/demos/OnB ... dDemo1.htm
关闭程序不会弹出确认对话框.

文件: https://dl.dropbox.com/u/13322788/wxactivex/wxactivex.zip [ ^ ]

We use an embedded browser to show a specific webpage that has a rich text editor.

This text editor has hooked itself onto some events to detect when the browser tries to close/leave the page. The editor will validate that the latest changes are saved, and if not it will prompt the user to do so.


If the page is opened in a standalone Internet explorer, both navigating away (by typing new url), and closing the tab/window, will trigger the javascript.


When the page is shown in the embedded Iwebbrowser2 control and we send a new url, the javascript is properly triggered. But we are unable to get the event for close.

When we close the frame the control is hosted in, all the panels/controls just gets destroyed.

How do I programmatically tell the Iwebbrowser2, that we are about to close?

I have also tried to call the Quit function when I receive the onCloseEvent for my frame.
Calling Iwebbrowser2::Quit has so far not worked at all. The function does always return e_fail.



I can demonstrate it with the wxactivex sample.
I have changed it to default open this url: http://www.4guysfromrolla.com/demos/OnB ... dDemo1.htm
Closing the program does not bring up the confirmation dialog.

File: https://dl.dropbox.com/u/13322788/wxactivex/wxactivex.zip[^]

推荐答案

以关闭命令"导航到预定义的链接.
使用BeforNavigate2检查新链接-如果它是预定义的链接,请关闭对话框.
Navigate to a predefined link as the ''close command''.
Use BeforNavigate2 to check the new link - if it is the predefined link close the dialog.


这篇关于iwebbrowser2 Javascript onQuit事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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