最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Javascript context menu for images - Stack Overflow

programmeradmin1浏览0评论

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!

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!

Share Improve this question edited May 3, 2010 at 21:25 Chris asked May 3, 2010 at 21:09 ChrisChris 27.4k49 gold badges206 silver badges357 bronze badges 4
  • 3 I hate it when people add this crap to their websites. If you want to annoy your users to all hell then do something like this. – DigitalZebra Commented May 3, 2010 at 21:19
  • 4 I don't think it makes a lot of sense to vote a question down because you don't like the implications of an implementation based on the answer. It's a perfectly reasonable question from the standpoint of software development. – Pointy Commented May 3, 2010 at 21:21
  • It's not about preventing them from downloading it nor annoying them, most of them WANT the help so they can post the images on other websites. – Chris Commented May 3, 2010 at 21:21
  • P.s. Thanks Pointy - It is impossible for you to know the context for the application for this code. Most of my users don't know that much about puters so any help I give them is better for them. What I'm trying to do is give a better user experience and reduce support emails. – Chris Commented May 3, 2010 at 21:23
Add a ment  | 

3 Answers 3

Reset to default 7

Don't send the image to their browser.

No. You can prevent the mon 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 ment..

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(...);
});

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

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

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

http://elliottback./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.

发布评论

评论列表(0)

  1. 暂无评论