Welcome to vbmods.rocks! Get FREE and paid vBulletin mods, plugins, addons, API extensions, custom modules, custom BB Codes, vBCloud mods, CORE hacks, JS hacks, custom coding by Glenn, an ex-vBulletin Developer. You must register before you can post, download the files or copy the code from the free plugins.
Glenn I'm looking for a javascript to disable right click for a specified usergroup and forum.. I'm hoping to just add the usergroup and forum number into the code
I know there are ways around it but that is ok
Thank you
Can I disable right click on my web page without using JavaScript? I ask this because most browsers allow user to disable JavaScript.
If not, how do I use JavaScript to disable right click?
I do not personally recommend this. But since you asked...
Code:
<script>
(function() {
var usergroupids = [1, 2, 3]; [COLOR=#008000]//Specify usergroup IDs here delimited by comma[/COLOR]
var callback = function(id) {
return document.querySelector('body[data-usergroupid="' + id + '"]');
}
if (usergroupids.some(callback)) {
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
//uncomment the alert statement below by removing the // if you need to display an alert message.
//alert("Sorry, you are not allowed to do this.");
});
}
})();
</script>
For vBCloud customers, add the above code in the Google or Bing Ownership Verification HTML tag option in Search Engine Tools in AdminCP.
For self-hosted customers, add the above code in the head_include template in Style Manager in AdminCP.
Last edited by glennrocksvb; 04-26-2019, 02:02 PM.
<script> (function() { var usergroupids = [22]; //Specify usergroup IDs here delimited by comma var callback = function(id) { return document.querySelector('body[data-usergroupid="22' + id + '"]'); } if (usergroupids.some(callback)) { document.addEventListener('contextmenu', function(e) { e.preventDefault(); //uncomment the alert statement below by removing the // if you need to display an alert message. //alert("Sorry, you are not allowed to do this."); }); } })(); </script>
I'm doing usergroup 22. did I insert it into the code properly?
<script>
(function() {
var usergroupids = [22]; //Specify usergroup IDs here delimited by comma
var callback = function(id) {
return document.querySelector('body[data-usergroupid="' + id + '"]');
}
if (usergroupids.some(callback)) {
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
//uncomment the alert statement below by removing the // if you need to display an alert message.
//alert("Sorry, you are not allowed to do this.");
});
}
})();
</script>
Here is what I did and its a no go.
Last edited by glennrocksvb; 04-26-2019, 04:55 PM.
Reason: Wrapped code in [code][/code] tags
Comment