• 点击鼠标获取元素ID


    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
    
        private mshtml.HTMLDocument doc = null;
    
    
    
        private void Form1_Load_1(object sender, EventArgs e)
        {
    
            txtRecord.Items.Add("start...");
            txtRecord.Items.Add("start2...");
            webBrowser1.Navigate("http://www.google.com");
        }
    
    
        private void webBrowser1_DocumentComplete(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
    
            txtRecord.Items.Add(e.Url.ToString() + " loaded...");
    
            if (doc == null)
            {
                doc = (mshtml.HTMLDocument)webBrowser1.Document.DomDocument;
                mshtml.HTMLDocumentEvents2_Event iEvent;
                iEvent = (mshtml.HTMLDocumentEvents2_Event)doc;
                iEvent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler);
    
            }
    
        }
    
        private bool ClickEventHandler(mshtml.IHTMLEventObj e)
        {
            txtRecord.Items.Add("clicked ==>" + e.srcElement.tagName);
            txtRecord.Items.Add("clicked2 ==>" + e.srcElement.getAttribute("name", 0));
    
            txtRecord.Items.Add("clicked3 ==>" + e.srcElement.innerHTML);
    
            return true;
        }
    
    
    }
  • 相关阅读:
    [编程题]多多的数字组合
    mac传输文件到服务器
    git 清除缓存、查看add内容
    go build
    vim编辑器
    Git: clone指定分支
    查看端口占用以及kill
    curl小记录
    Python3.9 malloc error: can’t allocate region
    设计模式-策略模式
  • 原文地址:https://www.cnblogs.com/ArRan/p/2997130.html
Copyright © 2020-2023  润新知