当右击“将图像保存为”时改变图像路径。 [英] Change image path when right click "save image as"

查看:112
本文介绍了当右击“将图像保存为”时改变图像路径。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在我的网页上显示没有水印的图片,当用户尝试通过右键单击菜单和将图片另存为来下载图片时。要让他们下载已应用了水印的图片?

Is it possible to have an image without watermark on my page and when people try to download the image by accessing the right click menu and "save image as". To let them download an image with the watermark applied to it?

推荐答案

所以显然你可以检查哪个鼠标按钮 mousedown 事件处理程序,如果是正确的按钮更改图像的来源:

So apparently you can check which mouse button was pressed in a mousedown event handler and if it was the right button change the source of the image:

​$('img').on('mousedown', function (event) {
    if (event.which == 3) {
        this.src = this.src.replace('.jpg', '_watermark.jpg');
    }
});​​​​​​​​​

这是一个演示: http://jsfiddle.net/s6A9m/

这篇关于当右击“将图像保存为”时改变图像路径。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆