Resources » Technical Tips » Web Development

Block the Right Clicking on page


Updated: Category: Web Development
Author: Member Level: GoldPoints: 3



You can block right clicking on your page. By this feature you can ensure that no one see your client side code by view source. And if you don't want that no one make copy of your page content then this will be helps you.
Normally if you make right click on web page then you can see that there are many options comes. In these option, the view source option is one of them. By this option you can see hole structure of your web page (like designing part) and you can also see the script part which will be use on that page.
So if you want to block all the options of page then you can use this line of code in tag in your page:

Body onContextmenu="return false"

By this single line of code , the right clicking becomes block.


Did you like this resource? Share it with your friends and show your love!

Responses to "Block the Right Clicking on page"
Author: guru prasad  20 Jan 2009   Member Level: Gold   Points : 1
This code is not working...

can you provide the technique with more explanation...

Also we can see the source code of the page using browser window tools menu. so how can we protect our code not to expose...

Thaning you...



Author: Narayanan S  21 Jan 2009   Member Level: Bronze   Points : 1
Hi,
I have tried the same code in ASP.NET(C# code) and it is working properly.
body MS_POSITIONING="GridLayout" oncontextmenu="return false"

Thanks



Author: Tarak  02 Feb 2009   Member Level: Bronze   Points : 0
Not working...


Author: Kusum  10 Feb 2009   Member Level: Bronze   Points : 0
Thx a lot....

It realy help me.

Thx & regard

Kusum



Author: shaikabbas  06 Apr 2009   Member Level: Gold   Points : 0
try this

body MS_POSITIONING="GridLayout" oncontextmenu="return false"



Author: subhashinichoudhary  30 Nov 2009   Member Level: Gold   Points : 1
ok its working properly you are right.but the source code will be opened from Browse....>Menu....>View....>Sourcecode.


Author: Sachin Kumar  21 Dec 2009   Member Level: Gold   Points : 1
source code can also be opened from Browse....>Menu....>View....>Sourcecode
Please also suggest to block this option.



Author: Prakash kumar pothal  18 Feb 2010   Member Level: Gold   Points : 2
Add this below code in ur javascript for Block the Right Clicking on page .if u have used the master page than put this code in the master page.Its working in all the pages if pages are inherited from the master page

This code is wokring on both for IE and FF.

var message = "function disabled";
function RightClickCheck(keyp) {
if (navigator.appName == "Netscape" && keyp.which == 3) { alert(message); return false; }
if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; }
}
document.onmousedown = RightClickCheck;




Regards,
prakash



Author: Developer  18 Feb 2010   Member Level: Gold   Points : 1
hi prakash,

it is not worked in IE.

only its working only in FF.
can u explain me why.



Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index
    Subscribe to Subscribers
    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    More...
     
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India