这个问题来自论坛提问,对dom稍微了解的话还是比较简单的,只要注册一下事件就可以了。

C#代码如下:

using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication5
...{
  public partial class Form1 : Form
  ...{
    public Form1()
    ...{
      InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    ...{
      this.webBrowser1.Navigate("");
      this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
    }

    void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    ...{
      if (e.Url.ToString() != this.webBrowser1.Url.ToString()) return;
      foreach(System.Windows.Forms.HtmlElement el in this.webBrowser1.Document.GetElementsByTagName("input"))
      ...{
        if (el.Name == "btnG")
        ...{
          el.Click += new HtmlElementEventHandler(Form1_Click);
        }
      }

    }

    void Form1_Click(object sender, HtmlElementEventArgs e)
    ...{
      MessageBox.Show("jinjazz pass");
    }

  }
}

WebBrowser中html元素如何触发winform事件的更多相关文章

  1. WebBrowser中html元素如何触发winform事件 z

    只要注册一下事件就可以了. C#代码如下: using System;using System.ComponentModel;using System.Windows.Forms; namespace ...

  2. js/jq 动态添加的元素不能触发绑定事件解决方案

    <!-- Copyright 2017-10-27, Jachin QQ: 381558301 Email: 381558301@qq.com 请看看你们的版本并对号入座: jquery1.6版 ...

  3. js添加的元素无法触发click事件

    动态生成的元素,使用.on绑定事件,比如$(document).on("click",".divclick",function(){})

  4. 用jquery追加的元素不能触发treeview事件

    在追加的元素后面添加: $("#navigation").treeview({ persist: "location", collapsed: true, un ...

  5. trigger(type,[data]) 在每一个匹配的元素上触发某类事件。

    trigger(type,[data]) 概述 在每一个匹配的元素上触发某类事件.大理石平台价格表 这个函数也会导致浏览器同名的默认行为的执行.比如,如果用trigger()触发一个'submit', ...

  6. JS事件 内容选中事件(onselect)选中事件,当文本框或者文本域中的文字被选中时,触发onselect事件,同时调用的程序就会被执行。

    内容选中事件(onselect) 选中事件,当文本框或者文本域中的文字被选中时,触发onselect事件,同时调用的程序就会被执行. 如下代码,当选中用户文本框内的文字时,触发onselect 事件, ...

  7. Webbrowser中IHTMLElement、IHTMLElement2、IHTMLDocument2、IHTMLDocument2属性介绍

    一.IHTMLElement接口        ele.click  -----------点击事件 ele.setAttribute(const strAttributeName: WideStri ...

  8. [转] C# Winform 拦截关闭按钮触发的事件

    原文 C# Winform 拦截关闭按钮触发的事件 用户关闭软件时,软件一般会给“是否确认关闭”的提示. 通常,我们把它写在FormClosing 事件中,如果确定关闭,就关闭:否则把FormClos ...

  9. 父元素onmouseover触发事件在父子元素间移动不停触发的问题

    今天写了一个侧边栏动态展开收缩的效果 <!DOCTYPE html> <html lang="en"> <head> <meta char ...

随机推荐

  1. Linux环境下NodeJS和MongoDB的安装配置

     一.NodeJS的安装配置 #进入安装目录cd /usr/local/ #删除原有安装rm -rf noderm -rf node-v0.10.29-linux-x64 #解压压缩包tar -zxv ...

  2. 根据时间获取最新数据 SQL(每一个人或者每一项)

    -- 方法1 select a.* from table1 a from table1 b where b.name=a.name and b.gdtime>a.gdtime) -- 方法2 s ...

  3. jquery 中 $ 符的意义

    $()就是一个函数名,别把它想得这么神奇.$就是一个字符,比如function a(){};function $(){};是一样的.只是jquery中习惯用$函数来作为对象化的入口而已.你也可以把jq ...

  4. 微信SDK 报错 invalid url domanin

    刚开始我在安全JS域名下填写: Http://hgj123.8.yydns.pw   带了Http 在微信中开打自己写好demo.报invalid url domanin 说我的无效URL. 然后我在 ...

  5. ViewPager一屏显示多个item,及边缘滑动事件优化

    关于ViewPager显示两边的item方法,网络上是方法都在ViewPager外包一个Layout, 然后设置ViewPager和外面的Layout的clipChildren="false ...

  6. apk签名打包时报master password is required to unlock the password database.错误,或者signtrue versions无法勾选,以及Error:Execution failed for task ':app:lintVitalRelease'.

    1.如果在签名时android studio报"Master password is required to unlock the password database.The passwor ...

  7. 关于Unity中DOTween插件的使用(专题一)

    DOTween flash里面的一个概念叫补间动画,DOTween就是干这个事情的. 补间动画:在1秒钟之内从A点移动到B点,在这个之间会把动画补间补好. 当我们安装好DOTween后,它就会提供很多 ...

  8. (转)YUV420、YUV422、RGB24转换

    //平面YUV422转平面RGB24static void YUV422p_to_RGB24(unsigned char *yuv422[3], unsigned char *rgb24, int w ...

  9. C# js 在页面能执行,放在单独js文件不能执行

    我们先来看看MVC中生成的 注意:url.Content 生成的路径 Html.ActionLink 与 Url.Action 1.两者者是根据给定的Controller,Action 生成链接, 但 ...

  10. k8s sidecar, Ambassador, Adapter containers

    When you start thinking in terms of Pods, there are naturally some general patterns of modular appli ...