tags:

views:

381

answers:

1

I'm using XPCOM, and I want to get the URI of the portion of a page the user clicks (e.g., a user right-clicks on a frame, and I want to display the URL of that frame). So I've set up a mouse listener (nsIDOMEventListener) and then when a click occurs, the handleEvent callback gives me access to the nsIDOMEvent.

My question is, how do I get the URI from the nsIDOMEvent?

+1  A: 

To answer my own question: on the event, call getTarget().queyInterface(NS_IDOMHTMLELEMENT_IID).getOwnerDocument(). queryInterface(NS_IDOMHTMLDOCUMENT_IID).getURL()

(The above is pseudo-code. You'll have to adapt it depending on the language you're using)

Dan