图像的 Javascript 上下文菜单

发布于 2024-08-31 07:59:10 字数 193 浏览 4 评论 0原文

我有一个网站,很多人都从上面复制图像,这很好。然而,我真正想做的是帮助他们将其嵌入到他们要去的目标网站上。

理想情况下,这将采取这样的形式:当用户右键单击图像时,将出现上下文菜单,为他们提供嵌入或共享图像的简单选项。

最好的方法是什么?

PS我根本不关心它们的热链接或保存图像,我只想为用户提供一种更简单的方式来共享图像!

I have a website where lots of people copy images off it, which is fine. What I do want to do, however, is help them embed it on the target website they are going to.

Ideally this would take the form where when a user right clicks the image a context menu will appear giving them easy options to embed or share the image.

What is the best way to do this?

P.s. I don't care about them hotlinking, or saving the images at all, all I want to do is provide the user with an easier way to share the images!

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

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

发布评论

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

评论(3

尬尬 2024-09-07 07:59:10

不要将图像发送到他们的浏览器。

Don't send the image to their browser.

等待圉鍢 2024-09-07 07:59:10

不会。您可以防止普通用户打扰,但事实是 URL 被发送到浏览器进行下载。所以至少我可以查看源代码并弄清楚它。

不过,如果您确实想惹恼用户,可以附加一个 oncontextmenu 事件,该事件将捕获某些浏览器中的右键单击。

编辑

回应您的评论..

由于您使用的是 jQuery,因此可以使用 此插件来检测右键单击。它已在大多数浏览器上进行了测试。

然后,您可以使用类似 SimpleModal 的内容来显示您想要向用户显示的模式框。

$('img').rightClick(function (e) {
    $.modal(...);
});

No. You can prevent the common user from bothering, but the fact is the URL is sent to the browser to download. So at the very least I could view the source and figure it out.

If you really want to try to annoy the user, though, you can attach an oncontextmenu event which will capture the right-click in some browsers.

edit:

In response to your comment..

Since you're using jQuery, you can use this plugin to detect right clicks. It has been tested on most browsers.

You can then use something like SimpleModal to display the modal box you want to show the user..

$('img').rightClick(function (e) {
    $.modal(...);
});
一枫情书 2024-09-07 07:59:10

实际上,您可以在除 IE 之外的所有主要浏览器中将 HTML 呈现为嵌入的 mime 数据:

http:// /jimbojw.com/wiki/index.php?title=Data_URIs_and_Inline_Images

另一个奇怪但可行的解决方案是将图像转换为 CSS:

http://elliottback.com/wp/convert-image-to-css/

这两个解决方案都不是一个很好的解决方案,但它强调了这样一个事实:需要愿意因为仅仅将其放在网络上而丢失图像。

即使你使用插件,人们也可以进行屏幕截图。

You can actually render HTML as embedded mime data in all major browsers except for IE:

http://jimbojw.com/wiki/index.php?title=Data_URIs_and_Inline_Images

Another weird, but workable solution is to convert the image to CSS:

http://elliottback.com/wp/convert-image-to-css/

Neither is really that great a solution, but it highlights the fact that you need to be willing to lose an image by just putting on the web.

Even if you use a plug-in, people can just do a screen capture.

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