Disable Right-Click

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

Mon Oct 15, 2012 10:21 am

I want to know the code for, disabling right click on my web pages so that no one see my source code.
Please, just help me out.

php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Mon Oct 15, 2012 11:14 am

your php code won't ever be displayed to the user as long as it's in a file with a .php extension. Even disabling right click doesn't protect your html/javascript source though, as users can save the file and edit that way, or hit their selection button beside their right control key and get the same list. If you still want to block right click, use javascript to set an even to the right click event, maybe an error message that says "stop it". Or you can right click redirect to a page that adds the ip of those that visit it to a blocked list. kind of a one strike and you're out thing. it's all doable but not really necessary if you keep your sensitive code in the PHP and not in html or javascript.

Post Reply