How to disable image download from browser?

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

gauravbhatt gravatar image gauravbhatt


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.


delete flag offensive retag edit



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

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

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

MVarun gravatar image MVarun flag of India
268 1 6

Here it is..


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

function clickIE() {
if (document.all) {
    return false;
function clickNS(e) {
if (document.layers || (document.getElementById && !document.all)) {
    if (e.which == 2 || e.which == 3) {
        return false;
 if (document.layers) {
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

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>() {
            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

1 follower



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

Seen: 20 times

Last updated: Mar 12 '14

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