Get hyperlink text on Chrome right click

In the Chrome extension I'm working on right now, there is a situation where the user right-clicked on this link:

<a href="http://www.google.com">Hello</a>

and selected a specific option from the extension’s context menu, I need the string “Hello” to be written in some form. As the context menu API shows , it's easy to capture text with a right-click or the actual hyperlink URL (in this case Google.com), as they appear in OnClickData, but I'm not sure how to capture the text from the link.

As a note, if a user selects a hyperlink and tries to use my context menu, it does not work. However, it works correctly if the user selects plain text. I have a “link” and the “selection” is included in the “contexts” when I create a context menu option.

+5
source share
1 answer

There seems to be no easy way to do this. But there are some workarounds until this function is implemented. From http://code.google.com/p/chromium/issues/detail?id=39507

" , , . Cloudboard: Script : document.activeElement . : document.activeElement.selectionStart, document.activeElement.selectionEnd, document.activeElement.value.substr() "

+1

All Articles