Forum

C#, WPF, webbrowser
 
Powiadomienia
Wyczyść wszystko

C#, WPF, webbrowser

1 Wpisy
1 Użytkownicy
0 Reactions
1,271 Widoki
0
Rozpoczynający temat

detect mouse click on link, a href

1 odpowiedź
0
Rozpoczynający temat
        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;
        }

Twoja odpowiedź

Nazwa autora

E-mail autora

Twoje zapytanie *

 
Podgląd 0 rewizje Zapisano
Udostępnij: