you need to sink the onclick event, see examples atHOWTO: Sink HTML Document Events for WebBrowser Host http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q246247&Handling HTML Element Events http://msdn.microsoft.com/workshop/browser/mshtml/tutorials/sink.asp?frame=trueinside the event handler, you will need to get the IHTMLEventObj interface using HRESULT IHTMLWindow2::get_event(IHTMLEventObj** p);then get its srcElement's interface IHTMLElement throughHRESULT IHTMLEventObj::get_srcElement(IHTMLElement** p);check its tagName property: HRESULT IHTMLElement::get_tagName(BSTR* p);if it is "IMG", then you try to query for its IHTMLImgElement interface, then get its src property: HRESULT IHTMLImgElement::get_src(BSTR* p);very complicated, isn't? while you can just do this in javascrript:<script language="javascript"> function document.onclick() { if (event.srcElement.tagName == "IMG") alert(event.srcElement.src); } </script>
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q246247&Handling HTML Element Events
http://msdn.microsoft.com/workshop/browser/mshtml/tutorials/sink.asp?frame=trueinside the event handler, you will need to get the IHTMLEventObj interface using
HRESULT IHTMLWindow2::get_event(IHTMLEventObj** p);then get its srcElement's interface IHTMLElement throughHRESULT IHTMLEventObj::get_srcElement(IHTMLElement** p);check its tagName property:
HRESULT IHTMLElement::get_tagName(BSTR* p);if it is "IMG", then you try to query for its IHTMLImgElement
interface, then get its src property:
HRESULT IHTMLImgElement::get_src(BSTR* p);very complicated, isn't? while you can just do this in javascrript:<script language="javascript">
function document.onclick()
{
if (event.srcElement.tagName == "IMG")
alert(event.srcElement.src);
}
</script>