如何在自定义上下文菜单中添加复制链接位置

发布于 2024-11-30 02:14:47 字数 237 浏览 3 评论 0原文

我正在开发一个 asp.net mvc 3 Web 应用程序。这里我需要添加自定义上下文菜单。因此,我禁用了默认的右键单击上下文,并添加了自定义上下文菜单的插件。

我试图在自定义菜单中添加一个项目,即:“复制链接位置”。这在浏览器中可用。

但问题是,如何检测用户右键单击了 html 链接?因为单击网页上的任意位置都会出现上下文菜单。和 另外,我如何复制该特定链接位置?从文档获取链接位置背后的 javascript 是什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

佼人 2024-12-07 02:14:47

请参阅动态右键单击上下文菜单以添加自定义右键单击上下文菜单。

要获取您选择的链接的 URL,您需要获取的是

anchor.getAttribute("href")

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")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文