7

In researching my Super User question How can I selectively disable paste blockers I discovered that the specific site I had a problem with did not appear to use any of the methods any of the existing solutions expected.

While the global solutions of using the dom.event.clipboardevents.enabled preference or Disable clipboard manipulations plugin in FireFox worked, they also also suffer the problem that there are legitimate reasons why websites might want to hook into onpaste (such as google docs rich text support or facebooks link handling) so I don't want that functionality completely disabled.

The solutions we have found (such as Derek Prior's Re-enabling Password Pasting on Annoying Web Forms and the improved Re-enabling Password Pasting on Annoying Web Forms (v2) by Chris Bailey) which use bookmarklets to selectively disable the functionality of paste blocking code don't appear to work with this page.

This makes me wonder, how does the petplanet website disable paste, why don't the existing solutions work with this site, and what other ways are there to prevent paste blocking? Answering these questions should help us write a comprehensive bookmarklet solution, so this pernicious practice can be worked around for good.

Community
  • 1
  • 1
Mark Booth
  • 7,605
  • 2
  • 68
  • 92

2 Answers2

2

You can jQuery paste event to listen for the event and use prevenrDefault() to prevent the event.

In this page , they used the below jQuery

$('#pwd, #pwd2').bind('paste',function(e){
    e.preventDefault();
    alert('Please type your password.')
});    

Open Firebug, Go to Scripts Tab, then search the string Please type your password. (Firebug Search Bar , not browser search bar.) , you'll find above code. And Code is present logon.asp

Image
To Disable it , you simply use off method like this $('#id1').off(). this unbinds all events for the element that has id='id1'

J Santosh
  • 3,808
  • 2
  • 22
  • 43
0

As far as I know, you can only 'disable' such things with JavaScript.

As I can imagine not really the answer you are looking for, you could do something like this:

var keys = [];
window.addEventListener("keydown",
    function(e){
        keys[e.keyCode] = true;
        checkCombinations(e);
    },
false);

window.addEventListener('keyup',
    function(e){
        keys[e.keyCode] = false;
    },
false);

function checkCombinations(e){
    // try and prevent cntrl+v (paste)
    if(keys["v".charCodeAt(0)] && e.ctrlKey){
        alert("You're not allowed to paste");
        e.preventDefault();
    }
}

Source: Get a list of all currently pressed keys in Javascript

Community
  • 1
  • 1
Tim Visser
  • 916
  • 9
  • 28