How to add copy link location in custom context menu
I'm developing an asp.net mvc 3 开发者_如何学运维web application. Here I need to add custom context menu. So I have disabled the default right click context and added a plugin for custom context menu.
I'm trying to add an item in the custom menu, namely: "Copy link location". Which is available in browsers.
However the problem is, how can I detect that the user right clicked on a html link? Because the context menu appears by clicking anywhere on the webpage. And also, how can I copy that specific link location? What is the javascript behind getting a link location from a document?
See Dynamic Right Click Context Menu for adding custom right click context menu.
For getting the URL of the link you have selected, all you need to get is
anchor.getAttribute("href")
精彩评论