User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,050 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,464 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1153 | Replies: 11 | Solved
Reply
Join Date: Jun 2008
Posts: 70
Reputation: Q8iEnG is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster in Training

How to Disable (View Source) and (Ctrl+C) from a site?

  #1  
32 Days Ago
Hi guys

Is there a chance to disable these two things from my site?
(View Source) and (Ctrl + C )

please, give me few minutes from your time and help, i'll be much more appreciated


thanks in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 538
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #2  
31 Days Ago
Champions Are Not SuperNatural,They Just Fought For One More Second When Every One Else Quit...Some times That One Second Of Effort Gives You The VICTORY...
Reply With Quote  
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 538
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #3  
31 Days Ago
For this I use onKeyDown event. See the following code
that disables CTRL C and CTRL V.

Note that this is not enough to prevent COPY/PASTE
in a text field, since the user can use CTRL INS, SHIFT INS
or simply use the context menu (right click on text field).

  1. <html>
  2. <head>
  3. <script language="javascript">
  4.  
  5. function onKeyDown() {
  6. // current pressed key
  7. var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
  8.  
  9. if (event.ctrlKey && (pressedKey == "c" ||
  10. pressedKey == "v")) {
  11. // disable key press porcessing
  12. event.returnValue = false;
  13. }
  14.  
  15. } // onKeyDown
  16.  
  17. </script>
  18. </head>
  19.  
  20. <body>
  21. <form name="aForm">
  22. <input type="text" name="aText" onkeydown = "onKeyDown()">
  23. </form>
  24. </body
  25. </html>
Last edited by Shanti Chepuru : 31 Days Ago at 2:00 am. Reason: used code tags
Champions Are Not SuperNatural,They Just Fought For One More Second When Every One Else Quit...Some times That One Second Of Effort Gives You The VICTORY...
Reply With Quote  
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 538
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #4  
31 Days Ago
how to disable ctrl+c:
http://www.faqs.org/faqs/msdos-progr...ection-16.html

And
That shortcut is handled by the operating system. It never reaches the browser and so the browser has no opportunity to pass it to the web page.

IE only:

Add the following code to your BODY tag:

ondragstart="return false" onselectstart="return false"
Champions Are Not SuperNatural,They Just Fought For One More Second When Every One Else Quit...Some times That One Second Of Effort Gives You The VICTORY...
Reply With Quote  
Join Date: Jun 2008
Posts: 70
Reputation: Q8iEnG is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster in Training

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #5  
31 Days Ago
Thanks a lot you did helped me a lot that's nice from you

thanks a lot, much appreciated
Reply With Quote  
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 538
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #6  
31 Days Ago
Fine....
Last edited by Shanti Chepuru : 31 Days Ago at 7:01 am.
Champions Are Not SuperNatural,They Just Fought For One More Second When Every One Else Quit...Some times That One Second Of Effort Gives You The VICTORY...
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,222
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 10
Solved Threads: 270
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #7  
31 Days Ago
As long you do not provide pure HTML site nothing is as it seems in source view...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Feb 2008
Location: Gurgaon India
Posts: 103
Reputation: nikesh.yadav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Junior Poster

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #8  
30 Days Ago
Shanti Chepuru

u done good work
Help as an alias

I think programming is great................
http://www.nikeshyadav.com
Reply With Quote  
Join Date: Jun 2008
Posts: 70
Reputation: Q8iEnG is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster in Training

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #9  
30 Days Ago
Yeah, he did
Reply With Quote  
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 538
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: How to Disable (View Source) and (Ctrl+C) from a site?

  #10  
29 Days Ago
thanks for ur compliments...
Originally Posted by Q8iEnG View Post
Yeah, he did

And im female....
Champions Are Not SuperNatural,They Just Fought For One More Second When Every One Else Quit...Some times That One Second Of Effort Gives You The VICTORY...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 11:47 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC