Hello,
The following code in a WPF app with a webbrowser object that should be able to recognize the clicked html element of a website and give me the tag name. This works in normal sites like Google, etc. HOWEVER, these code is not working in some internal websites from our company.
For example, it works in this Google input object (text box) and shows tag name
INPUT
<input class="gLFyf gsfi" maxlength="2048" name="q" type="text" jsaction="paste:puy29d" aria-autocomplete="both" aria-haspopup="false" autocapitalize="off" autocomplete="off" autocorrect="off" autofocus="" role="combobox" spellcheck="false" title="Search" value="" aria-label="Search" data-ved="0ahUKEwjfkO_z95LvAhXuMlkFHWsqBwEQ39UDCAY">
But, it doesn't work in this input object (text box) from our internal websites, and the click event is not even triggered.
<input id="Component24ff2cb_findCriteria" title="Search for records" hintlabelid="Component24ff2cb_findHintText" type="text" class="ms-crm-Dialog-Lookup-QuickFind" maxlength="100" tabindex="0" value="">
Any suggestion will be appreciated.
What I have tried:
public MainWindow()
{
InitializeComponent();
webBrowser1.LoadCompleted += new
LoadCompletedEventHandler(webBrowser1_LoadCompleted);
}
private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
{
mshtml.HTMLDocument doc;
doc = (mshtml.HTMLDocument)webBrowser1.Document;
mshtml.HTMLDocumentEvents2_Event iEvent;
iEvent = (mshtml.HTMLDocumentEvents2_Event)doc;
iEvent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler);
}
private bool ClickEventHandler(mshtml.IHTMLEventObj e)
{
textBox1.Text= e.srcElement.tagName
return true;
}