Disable Right Click on your website

MD Taseen Khan, Disable Right Click
Back

Before starting about it, lets understand some FAQs

What is Disable Right Click ??

If your goal is to disallow users to simply save your images, you can also check if the clicked target is an image, only disable right click in that case. So right click can be used for other purposes.

Why do people disable right click?

Many a times, websites disable the right click option, because of copyright issues as they do not want their content to be noted down.

Does disabling right click Hurt SEO?

Google's John Mueller said on Twitter that disabling the right click on your web pages and/or disabling the ability to select content on your web pages, has no impact on your SEO or rankings.

What happen when we do blocking and right click?

When a website blocks right-clicks, they do it through JavaScript. However, because most JavaScript tends to run client side you retain a certain amount of control over it: If you want to disable the block, you'll need a solution that can disable all or part of the JavaScript on a site.

After a bit while here is the JavaScript code for disabling right click on your website to protect your content.

<script>
var isCtrl = false;

document.onkeyup = function (e) {

if (e.which == 17)

isCtrl = false;

}

document.onkeydown = function (e) {

if (e.which == 123)

isCtrl = true;

if (((e.which == 85) || (e.which == 65) || (e.which == 88) || (e.which == 67) || (e.which == 86) || (e.which == 2) || (e.which == 3) || (e.which == 123) || (e.which == 83)) && isCtrl == true) {

alert('WE HAVE DISABLED THIS FUNCTION FOR SECURITY REASONS');

return false;

}

}

// right click code By MD Taseen Khan

var isNS = (navigator.appName == "Netscape") ? 1 : 0;

if (navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);

function mischandler() {

alert('Sorry you can not copy anything from this website ');

alert('Rather than copying you can share the link of the post or the website ');

alert('Thank You 😊  ');

return false;

}

function mousehandler(e) {

var myevent = (isNS) ? e : event;

var eventbutton = (isNS) ? myevent.which : myevent.button;

if ((eventbutton == 2) || (eventbutton == 3)) return false;

}

document.oncontextmenu = mischandler;

document.onmousedown = mousehandler;

document.onmouseup = mousehandler;

//select content code disable alok goyal

function killCopy(e) {

return false

}

function reEnable() {

return true

}

document.onselectstart = new Function("return false")

if (window.sidebar) {

document.onmousedown = killCopy

document.onclick = reEnable

}
</script>

I have added the

<script> </script>

tag so that you can put the code into your website.

© MD Taseen Khan.🌐
DMCA.com Protection Status