Forum

C#, WPF, webbrowser
 
Notifications
Clear all

C#, WPF, webbrowser

1 Posty
1 Users
0 Likes
994 Widok
0
Topic starter

detect mouse click on link, a href

1 Answer
0
Topic starter
        private void web_LoadCompleted(object sender, NavigationEventArgs e)
        {
		
			//web - name of webbrowser component 
            HTMLDocument doc = (HTMLDocument)web.Document;
            HTMLDocumentEvents2_Event htmlEvents = (HTMLDocumentEvents2_Event)doc;
            htmlEvents.onclick += new HTMLDocumentEvents2_onclickEventHandler(htmlEvents_onclick);

        }
		
		private bool htmlEvents_onclick(IHTMLEventObj pEvtObj)
        {
            var html_element = (pEvtObj.srcElement as IHTMLElement);
            var html_ahref = (html_element as IHTMLAnchorElement);

            try
            {
                MessageBox.Show(html_ahref.href);
            }
            catch (Exception)
            { }

            return true;
        }

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: