How to disable right click on a html or JSP page

There can be requirements when you do not want users of your web application to right-click and view the html source.
Put following snipped in your html/jsp page’s header and user won’t see right-click context menu.


	function ieClicked() {
		if (document.all) {
			return false;
	function firefoxClicked(e) {
		if(document.layers||(document.getElementById&&!document.all)) {
			if (e.which==2||e.which==3) {
				return false;
	if (document.layers){
	document.oncontextmenu=new Function("return false")


, , , , ,

  1. #1 by rajesh on January 11, 2013 - 11:15 AM

    working fine .. tks a lot

  2. #2 by Navya on November 7, 2013 - 5:29 AM

    Hi Thank U so much.. Its working great

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: