Hi!
I'm trying to build a safari extenstion (mostly for learning purposes) that creates a delicious bookmark, when the user right clicks on a link. I've watched the WWDC Creating a Safari Extension video and everything is working fine.
Except that i don't have a clue how to find out if the user clicked on a link (or just some text) and if so, get it's url and title. What i got so far is this:
document.addEventListener("contextmenu", handleContextMenu, false);
function handleContextMenu(event){
safari.self.tab.setContextMenuEventUserInfo(event,getSelection().toString());
}
But this obviously only gives me a string of the selection. Now, according to the Safari Reference Library getSelection()
returns a DOMSelection
object. But even there i'm not able to spot a method that gives me a handle on the selected link.
As you might notice, i'm fairly new to this whole javascript and DOM stuff, so please excuse if this is an obvious question :)
Ciao, Sven