标题: webbrowser控件如何接收鼠标事件 [打印本页] 作者: yangying 时间: 2013-5-4 10:11 标题: webbrowser控件如何接收鼠标事件 在开发中,webbrowser控件如何接收鼠标事件,很多事情其实自己动动脑子就有办法的。主要是3步,给dom对象插入js脚本去响应鼠标-〉通过url跳转去通知webbrowser-〉截获跳转事件去c#中处理就可实现了
示例代码:[code=csharp]using System;
using System.Windows.Forms;
using mshtml;
using SHDocVw;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.webBrowser1.Navigating += new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);
this.webBrowser1.Navigate("");
SHDocVw.WebBrowser wb = this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser;
wb.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(wb_NavigateComplete2);
}