-2

I have an HTML code that contains a tag, a tag contains a link for my server uploaded file path whenever I click on the link that is redirecting to other tab showing file like image(should be viewable) and also giving the file to save on right mouse click. The downloading from browser I need to prevent. Any Plugin is there to prevent from the download.

<a href='http://localhost/admin/file/file.png'>File</a>
Samson
  • 352
  • 1
  • 11

2 Answers2

0
document.addEventListener('contextmenu', event => event.preventDefault());

Try this it will prevent right click and you can also use watermark and also you can't block print screen

sidrao2006
  • 1,228
  • 2
  • 10
  • 32
0

Hope it helps.

$(document).ready(function(){
    document.onkeydown = function(e) {
        if (e.ctrlKey &&
            (e.keyCode === 67 ||
                e.keyCode === 86 ||
                e.keyCode === 85 ||
                e.keyCode === 117)) {
            return false;
    } else {
        return true;
    }
};
$(document).keypress("u",function(e) {
    if(e.ctrlKey)
    {
        return false;
    }
    else
    {
        return true;
    }
});

});
Anshu
  • 1,277
  • 2
  • 13
  • 28
Kevin
  • 1,241
  • 7
  • 20