How to detect a click event on an anchor used in a div?

Add-in Express™ Support Service
That's what is more important than anything else

How to detect a click event on an anchor used in a div?
 
SilverStr




Posts: 28
Joined: 2013-03-31
OK, so I am finding the power of the Add-In Express world. But as I progress in the testing, I am coming across interesting ways webmasters are screwing with traditional forms, making it difficult to get my work done.

Let me give you an example. Here is Dell's login page: http://ecomm.dell.com/myaccount/login.aspx

Notice how there is a "Sign In" button that looks like a green pill. That isn't a standard input button or even an input image. Instead, it seems to show in dxiehtmlDocEvents_OnClick() as an HTMLDivElementClass.

I am intercepting anchors in OnClick, so why is it showing as a div?

What I want is to detect what caused the click event, and record it. In this case, it would be the underlying anchor tag that shows as:

<a href="javascript:Validate();" style="text-decoration:none">

As I try to crawl the stack I am not finding that href anywhere. How do I go about getting it from the HTMLDivElement in OnClick()? Or alternatively, how can I capture the click on the anchor and actual see it come in as a HTMLAnchorElement (or something similar)?
Posted 03 Apr, 2013 17:55:40 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Dana,

When I click on the 'Sign-in / Register' link I get the anchor element. What version of IE do you use?
Posted 05 Apr, 2013 05:30:18 Top
SilverStr




Posts: 28
Joined: 2013-03-31
I am testing on IE9 and IE10. (Win7 and Win8)
Posted 05 Apr, 2013 10:12:59 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
I also tested it in Win7+IE10.

Here is my code:
        private void adxiehtmlDocEvents1_OnClick(object sender, object eventObject, ADXCancelEventArgs e)
        {
            mshtml.IHTMLEventObj2 eventObj = eventObject as mshtml.IHTMLEventObj2;
            if (eventObj != null && eventObj.srcElement != null)
            {
                if (eventObj.srcElement is mshtml.IHTMLAnchorElement2)
                {
                }
            }
        }


The SupportedEvents property of the 'ADXIEHTMLDocEvents' component is set to 'Anchors'.
Posted 05 Apr, 2013 10:38:02 Top
SilverStr




Posts: 28
Joined: 2013-03-31
I think the problem I have is that the SupportedEvents I am monitoring for include a whole lot more, so its getting called quite a bit.

As an example, I have to monitor the clicking of divs because some websites actually build their "s ubmit" buttons off of div tags with javascript actions. (Ya, it's stupid). So what happens in Dell's site as an example, I am getting an entry for the surrounding div instead of the anchor.

This afternoon I will look deeper to see if I can give you more detailed information to help explain how I am seeing it happen. With the weekend I don't expect I will hear back from you, but hopefully we can pick this up when you are back in the office.

Have a great weekend!
Posted 05 Apr, 2013 11:21:55 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Dana,

Thank you. Please ask me any questions.
Posted 08 Apr, 2013 09:34:23 Top