DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: can i prevent copy and paste in a document?

  1. #1
    EG Guest

    can i prevent copy and paste in a document?


    Hello,

    I am trying to prevent the user from copying and pasting the contents of
    a HTML page through the keyboard shortcuts. Is there any cross-browser way
    of doing this? Please advise. Thank you.

  2. #2
    KC Guest

    Re: can i prevent copy and paste in a document?

    Hi
    Well .... there are many ways apart from Ctrl+C and Ctrl+V which would
    enable a user to copy and paste from your HTML page.

    However if you want to prevent users from Copy-Paste the standard way, you
    could write a small script wherein you check the ascii values of the button
    being pressed and give an alert on pressing of the button.

    For example. You could give an alert when the user tries to press the "Ctrl"
    button by trapping its ascii value or for the right click of the mouse.

    function copyPaste(evt)
    {

    if(evt == 17 || evt == 93 || evt == 18)
    {
    alert("oops!")
    }
    }

    The above code stops a person using the "Ctrl" button, the "Alt" button
    (Alt+E+A) can also be used to copy and the "right click" button on the
    keyboard, So you see, most of it is handled. but one can still copy and
    paste from the IE menubar. If you get a solution to that ... please mail me.

    function rightClickCheck(evt) ---- FOR MOUSE RIGHT CLICK
    {
    if(evt.button == 2)
    {
    alert(oops again")
    }
    }


    Hope this helps

    Cheers
    KC

    EG <leg@pl.jaring.my> wrote in message news:3a1dd718$1@news.devx.com...
    >
    > Hello,
    >
    > I am trying to prevent the user from copying and pasting the contents of
    > a HTML page through the keyboard shortcuts. Is there any cross-browser

    way
    > of doing this? Please advise. Thank you.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center