+ Start a Discussion
Mohammed Zabi 1Mohammed Zabi 1 

ctrl+v and ctrl+c should be disable on vf page

Hi all,

  I need to remove ctrl+c and ctrl+v on visualforce page using javascript i was tried but this javascript is not working in internet explorer,
please give me so other idea to disable ctrl+c and ctrl+v on visualfoce page input text component using jquery or some thing
 
kiranmutturukiranmutturu
function disableselect(e) {
    return false;
}

function reEnable() {
    return true;
}

document.onselectstart = new Function("return false");

if (window.sidebar) {
    document.onmousedown = disableselect;
    document.onclick = reEnable;
}

Place this in your <head> tags and the user cannot select text on your page.However, there is no guarantee way to prevent your contents from being stolen.The JavaScript above can be easily bypassed by an experience internet user. E.g. If the browser's JavaScript is disabled, the code will not work. 
$(document).ready(function()
{
    var ctrlDown = false;
    var ctrlKey = 17, vKey = 86, cKey = 67;

    $(document).keydown(function(e)
    {
        if (e.keyCode == ctrlKey) ctrlDown = true;
    }).keyup(function(e)
    {
        if (e.keyCode == ctrlKey) ctrlDown = false;
    });

    $(".no-copy-paste").keydown(function(e)
    {
        if (ctrlDown && (e.keyCode == vKey || e.keyCode == cKey)) return false;
    });
});

other way... 
 
Mohammed Zabi 1Mohammed Zabi 1
Hi kiran,
  thanks for u r replay, can i get jquery  for bellow function

$(document).ready(function() { var ctrlDown = false; var ctrlKey = 17, vKey = 86, cKey = 67; $(document).keydown(function(e) { if (e.keyCode == ctrlKey) ctrlDown = true; }).keyup(function(e) { if (e.keyCode == ctrlKey) ctrlDown = false; }); $(".no-copy-paste").keydown(function(e) { if (ctrlDown && (e.keyCode == vKey || e.keyCode == cKey)) return false; }); });
 
Mohammed Zabi 1Mohammed Zabi 1
Thanks kiran it is working fine
one more help from u i need to disable right click copy in visualforce page can you please help me on that