This is what I ended up doing. Luckily, I'm only interested in IMG
element, and that is one of the options for extensions. I then use
messages to communicate between tabs and the background. It's working
On Nov 8, 3:23 pm, Arne Roomann-Kurrik <
kur...@chromium.org> wrote:
> Right on, I forgot about the contextmenu event. That might be a good
> workaround for getting a handle to any clicked on dom element, not just
> images.
>
> ~Arne
>
>
>
>
>
>
>
> On Fri, Nov 5, 2010 at 9:06 PM, Afuna Matata <
afunamat...@gmail.com> wrote:
> > I'd love to have that added to the API, and have starred accordingly.
>
> > In the meantime, I've used this workaround in my own extension (which
> > handles links not images, but same deal):
>
> > use document.addEventListener( "contextmenu", function... ) from a content
> > script. If event.target is an image, then extract the attributes you need
> > and pass it as a message to your extension.
>
> > You could also add the event listener on the images instead of the
> > document, but that won't work if the image you clicked on was created
> > dynamically.
>
> > On Sat, Nov 6, 2010 at 6:36 AM, Arne Roomann-Kurrik <
kur...@chromium.org>wrote:
>
> >> I agree with the need to update the API, but thought up of a workaround in
> >> the meantime - you can inject a content script in the page that keeps a
> >> reference to the dom target of any mouse clicks and use message passing to
> >> get that value from your context menu handler. Not very elegant, but might
> >> be useful in the meantime.
>
> >> Here's a codelab I wrote for a slightly different use case: