0

How to disable image download from browser?

asked 2014-03-12 11:03:39 +0800

gauravbhatt gravatar image gauravbhatt
45

Hi,

There is a requirement in our project to disable image download using right click 'Save Picture As' option on browser. Is it possible in ZK to disable by setting any property on AImage or zk.xml

Thanks in advance.

Gaurav

delete flag offensive retag edit

Comments

1

One way is to disable rightclick, then we can avoid it... Conform me so that i can help you.

MVarun ( 2014-03-12 11:09:04 +0800 )edit
1

another alternative is to set an empty popup to your component / overwrite the "right_click" listener, so the standard "save as" dialog is hidden.

IngoB ( 2014-03-12 11:13:26 +0800 )edit

Thanks MVarun and IngoB. Can you please suggest any reference for disabling right click if it is possible.

gauravbhatt ( 2014-03-12 11:48:13 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-03-12 12:27:17 +0800

MVarun gravatar image MVarun flag of India
268 1 6

Here it is..

noRightClick.js

var message = "Sorry, right-click has been disabled";

function clickIE() {
if (document.all) {
    (message);
    return false;
}
}
function clickNS(e) {
if (document.layers || (document.getElementById && !document.all)) {
    if (e.which == 2 || e.which == 3) {
        (message);
        return false;
    }
}
 }
 if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = clickNS;
 } else {
document.onmouseup = clickNS;
document.oncontextmenu = clickIE;
  }
 document.oncontextmenu = new Function("return false");

Step-1: Add this noRightClick.js file into your workspace under webContent folder.

Step-2: Which ever page you want to disable right Click write the following code after window tag.

                    <script src="/noRightClick.js"/>

Thus right Click is Disabled in that page.

Have Fun with ZK..

M Varun.

link publish delete flag offensive edit
0

answered 2014-03-12 12:23:32 +0800

IngoB gravatar image IngoB flag of Germany
256 6
image.addEventListener(Events.ON_RIGHT_CLICK, new EventListener<Event>() {
            @Override
            public void onEvent(Event event) {                
            }
        });
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-03-12 11:03:39 +0800

Seen: 21 times

Last updated: Mar 12 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More