0

I want to disable right click link and i found this code:

    <script type="text/javascript" language="javascript">
        $(document).ready(function()
        {
           $('body').on('contextmenu', 'a', function(e){ return false; });
        }); 
    </script>

I want to add on a specific domain. something like this code (adfly fullpage script)

    <script type="text/javascript">
        var ad5fly_id = 4484512;
        var ad5fly_advert = 'int';
        var domains = ['depositfiles.com', 'rapidshare.com'];
    </script>
    <script src="https://cdn.adf.ly/js/link-converter.js"></script> 

Basically, I dont want visitor to right click on my ad5fly link because they can bypass it easily. im talking about this: http://ad5f.ly/4484512/www.google.com : they can copy it and copy only the google link . then i wont earn any. help me guys. thanks !!

sorry for my bad english

Ian Oderon
  • 13
  • 5
  • You can disable right click but there are still ways around it, for example to disable Javascript in your browser or use Developer toolbar. – putvande Jul 04 '13 at 16:21
  • I see. But they can't open my blog unless they activate the js. btw thanks for the info – Ian Oderon Jul 04 '13 at 16:46

3 Answers3

0

Haven't tested this, but this is the solution from this thread here:

Disabling right click on images using jquery

$('body').bind('contextmenu', function(e) {
    return false;
});

If that doesn't work, you could also try attaching the function you document or window instead.

Community
  • 1
  • 1
relic
  • 1,662
  • 1
  • 16
  • 24
0

This is what you might be looking for

<script type="text/javascript">
    $(document).load(function(){
       $('body').on('contextmenu', 'a[href*=ad5f]', function(e){
            e.preventDefault();
            //or return false; does the same
        });
    }); 
</script>

If the anchor have a href which contains ad5f somewhere, then the contextmenu will be prevented.

Update: I've added to be on LOAD instead of READY because if on ready, it might trigger before the link-converter.js ended doing it's thing (swapping urls) and the selector might fail.

RaphaelDDL
  • 4,452
  • 2
  • 32
  • 56
0

You could iterate through the domains and cancel the right-click menu on page load.

  var domains = ['depositfiles.com', 'rapidshare.com'];
  for (var i = domains.length - 1; i >= 0; i--) {
    $('body').on('contextmenu', 'a[href*="'+domains[i]+'"]', function(e){ return false });
  };
Tyler Diaz
  • 152
  • 1
  • 9