disable ctrl+v+z (help me)

Discussion in 'HTML / PHP / JavaScript / CSS' started by black18, Sep 18, 2012.

  1. hi

    i have a chat room and use a html page

    i want to disable ctrl v and ctrl z for disable paste in chat room

    i use et-chat script

    i need a <SCRIPT LANGUAGE="JavaScript"> code for this page

    any can help me ? thank alot

    :)
     
  2. thanks
    but this code only for disable ctrl+v

    i want to disable ctrl+z and ctrl+v :)
     
  3. My brain automatically ignored this point because it seemed to make no sense. Does ctrl-z mean the same to you as it does to me - an undo action in the browser? If so, I don't understand why it's important to disable this.

    Regardless of that, the original stackoverflow link is still valid because it includes some sample js code that demonstrates how you can disable a keypress combination of ctrl + whatever
     
  4. yes i want to disable ctrl key in html page with js code :)
     
  5. Try this - my regurgitation and reimplementation of the useful bits in the stackoverflow post: http://jsfiddle.net/jlippa/7QTCD/

    Click run and then try hitting ctrl-v or ctrl-z; these key down events are disabled.
     
  6. I don't understand

    how to use in this html page ( body or head ??)

    how to use whith js ?

    thanks
     
  7. This is jQuery js code. jQuery is the #1 cross browser compact JavaScript library for simplifying dom manipulation, document event handling, ajax calls etc. The sample that I've put together for you works and meets the requirement that you asked about in your post; you can execute it and see it running it for yourself so there's no doubt about the fact that this does work and does what you want it to do.

    If you want to learn about jQuery you can start here: http://jquery.com/
    If you prefer to not use jQuery for some reason / if you're seeking vanilla js code, you'll have to seek an alternative solution from someone else.
     
  8. hi again

    Attached my html page

    you put the code for me. i did not understand
    :):(
     
  9. No I'm not prepared to implement this in your page for you. If I were to agree to do that I'm sure the support requests would never end. Couple this with the fact that what you've included in the zip file means I wouldn't be able to test what I implement anyway because you've supplied a mix of php code (completely useless to me) and other js and css dependencies that you haven't included.

    If you want to try the solution that I provided in your page yourself you'll need to:
    1) Include a reference to jQuery in your page within the head element just like the other js references you already have there.
    2) Include the js I supplied anywhere either in the document or perhaps in another additional new js include file.
    3) Debug it yourself when you find it doesn't work in your page on your server for whatever reason.
     
  10. Hi..All.
    You can try to mixed JSCode as below :
    <script language="javascript">
    function onKeyDown() {
    // current pressed key
    var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
    if (event.ctrlKey && (pressedKey == "c" ||
    pressedKey == "v" ||
    pressedKey == "Z")) {
    // disable key press porcessing
    event.returnValue = false;
    }
    } // onKeyDown
    </script>
    <script language='javascript'> //function for to disable ctrl event of the page.
    function document.onkeydown()
    {
    if ( event.keyCode==17) //17 is ascii code for ctrl
    {
    event.keyCode = 0;
    event.cancelBubble = true;
    return false;
    }
    }
    </script>

    Note : Put the code between <head>....</head>
     

Share This Page