How to Disable right click in Xenforo 2

  • Join us to download any resource for free. You will be able to download or guest post.
    Sign Up Now
Here is what I found.

Goto Admin Control Panel > Appearance > Templates > edit "PAGE_CONTAINER"

Paste this code at the end, just before the "</xf:macro>" tag.

Code:
<xf:if is="!{$xf.visitor.user_id}">
<script type="text/javascript">
<!--

//Disable right mouse click Script
//By Maximus ([email protected]) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="You need to login to right click";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>
</xf:if>
 
  • Like
Reactions: Hadia

Similar threads

March 2024

Total amount
$38.00
Goal
$250.00
Donation ends:

Staff online

Members online

Forum statistics

Threads
9,024
Messages
22,621
Members
51,460
Latest member
Imran786

About us

  • Our community has been around from 2017 and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. Providing Free Resources to help newcomers/startups. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu