The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Right click disabled for guests only

View previous topic View next topic Go down

Solved Right click disabled for guests only

Post by Mimóza on April 26th 2016, 11:57 am

Technical Details


Forum version : #PunBB
Position : Founder
Concerned browser(s) : Other
Screenshot of problem :
Who the problem concerns : All members
When the problem appeared :
Forum link : http://www.graphicballoon.com/

Description of problem

Hello everyone,
I have added a script to my site, which disables the right click option for everyone. However, it is rather bothersome for the members, so I'd like to ask if it was possible to add a code that disables the right click option only for guests and members are free to continue using it.

The code I'm using now:
Code:
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Ask before you take something. :)";

///////////////////////////////////
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")

// -->

Thanks in advance for any help! alien


Last edited by Mimóza on April 26th 2016, 12:58 pm; edited 1 time in total

Mimóza
Forumember

Female Posts : 541
Reputation : 241
Language : :)
Location : @Graphic Balloon

http://www.graphicballoon.com/

Back to top Go down

Solved Re: Right click disabled for guests only

Post by Ange Tuteur on April 26th 2016, 12:40 pm

To be honest, disabling right click / context menu achieves nothing but annoying your users. You can just disable JavaScript or open the devtools and take the code, image, etc.. From one developer to another ; You cannot protect your source code, images, etc.. on the internet. If it's out there and they want it, they'll find a way to get it.

That being said.. if you're really hellbent on barring people ( well, guests ) from their context menus, the following script should work just fine.
Code:
(function() {
  window.fa_alert_msg = 'Ask before you take something. :)';

  document.oncontextmenu = function() {
    alert(fa_alert_msg);
    return false;
  };
 
  $(function() {
    // remove event handler for members
    if (_userdata.session_logged_in) {
      document.oncontextmenu = null;
    }
  });
 
}());

Personally, I'd recommend making the topics or forum unviewable to guests if you really want to stop them from looking at / taking content, as the prior solution is a controversial one and really only achieves a false sense of security ; they'll still be able to take your content if they really want it.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Right click disabled for guests only

Post by Mimóza on April 26th 2016, 12:57 pm

Hello Ange,
Thanks sooo much for the code! Works great, as always! Very Happy 
As for the advice, yeah, I am aware of the negative side effects this can bring, however, I think making the forum unviewable is a risky choice as well for a design forum. For example, the Graphic Balloon's strongest point for now is the section where graphics are shared, if we were to hide it, I guess even less people would be motivated to join.  
I'm also aware of that there are possible ways of getting around this script, but even if only a small amount of people will be stopped from taking the images without a word, I'd like it to be added.  

Thank a lot for your input and concerns, I really appreciate it! 
Solved.

Mimóza
Forumember

Female Posts : 541
Reputation : 241
Language : :)
Location : @Graphic Balloon

http://www.graphicballoon.com/

Back to top Go down

Solved Re: Right click disabled for guests only

Post by Ange Tuteur on April 26th 2016, 1:09 pm

Anytime Doff

It'll most likely stop some, but I figured I'd let you ( and anyone else ) know that it's not a sure-fire way.

Anyway, have a good day. Wink

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Right click disabled for guests only

Post by SLGray on April 26th 2016, 9:27 pm

Topic solved and archived


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 35653
Reputation : 2375
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum