Right click disabled for guests only Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
3 posters

    Right click disabled for guests only

    Mimóza
    Mimóza
    Forumember


    Female Posts : 678
    Reputation : 278
    Language : Hungarian, English

    Solved Right click disabled for guests only

    Post by Mimóza 26/4/2016, 16:57

    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:

    Thanks in advance for any help! alien


    Last edited by Mimóza on 26/4/2016, 17:58; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Right click disabled for guests only

    Post by Ange Tuteur 26/4/2016, 17:40

    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.
    Mimóza
    Mimóza
    Forumember


    Female Posts : 678
    Reputation : 278
    Language : Hungarian, English

    Solved Re: Right click disabled for guests only

    Post by Mimóza 26/4/2016, 17:57

    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. Right click disabled for guests only 1f614 
    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. Right click disabled for guests only 1f609 

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


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Right click disabled for guests only

    Post by Ange Tuteur 26/4/2016, 18:09

    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
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51500
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Right click disabled for guests only

    Post by SLGray 27/4/2016, 02:27

    Topic solved and archived



    Right click disabled for guests only Slgray10

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