Streaming live at 10am (PST)

Disabling copy paste (cntrl +c, cntrl +v) from the site


#1

Is there a way to do that?
besides disabling right click on the site.


#2

http://www.hypergurl.com/norightclick.html
Boom smiley


#3

Thanks @Waldo_Broodryk, i was wondering where you are! smile

But that's for disabling right click, i can still highlight a text section and then (cntrl +c, cntrl +v) copy paste them, how do i disable that?


#4

Haha, it has information on how to do it is on the page. smile I'll type of our once I'm home 😁


#5

Should just be the following @Nir. Add the following html code to your BODY tag:


<body ondragstart="return false" onselectstart="return false">

Haven't tested it yet.


#6

Wrap this with <script></script> tags and put it in Footer Code in site dashboard Custom Code section.
You can adjust that to ANY character pressed with CTRL key. Look at the following website with keycodes: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

You're welcome :)

$(document).keydown(function(e) {
  // 67 == C
  if (e.keyCode == 67 && e.ctrlKey) {
    e.preventDefault();
    console.log('no no no. you cant ctrl+c');
  }

  // 86 == V
  if (e.keyCode == 86 && e.ctrlKey) {
    e.preventDefault();
    console.log('no no no. you cant ctrl+v');
  }
});

#7

@bartekkustra You are truly the Javascript ninja! Thanks man!!!


#8


#9

What about for macs? Do I just change the ctrl to cmd?


#10

Unlike Shift/Alt/Ctrl, Mac/Apple key is not considered as a modifier key--instead, you should hook on keydown/keyup and record when a key is pressed and then depressed based on event.keyCode.

Unfortunately, these key codes are browser-dependent:

Firefox: 224
Opera: 17
WebKit (Safari/Chrome): 91 (Left Apple) or 93 (Right Apple)

from


#11

@bartekkustra your awesomeness is awesome.

Thank you!


#12

@bartekkustra hope you don't mind me asking you another question.

Have any idea how to create this "soft" scrolling effect?
http://www.werkstatt.fr

Just to ease the scrolling so it wont be so "sharp".

Thank you!


#13

I don't mind :) Unfortunately for now I have no idea how to create such thing... I might need to work on that. Drop me that question at www.laitart.pro so I won't forget that.


#14

Hi @bartekkustra thanks! Just did.


#15

@bartekkustra this kinda works, not 100% the same like the link, but it does the job.

var $window              = $(window),
scrollDistance   = 170,
scrollSpeed      = 400,
scrollEffect     = 'swing',
scrollAmount     = 1,
smoothScroll;

if (! ('ontouchstart' in document.documentElement) && ! $('body').hasClass('modal-open')) {

    $window.on("mousewheel DOMMouseScroll", function (event) {

        event.preventDefault();

        if (smoothScroll) {

            // Start scrolling while waiting for final scoll amount (user stopped wheeling)
            if (scrollAmount == 1) {
                var delta = event.originalEvent.wheelDelta / 120 || -event.originalEvent.detail / 3;
                var finalScroll = $window.scrollTop() - parseInt(delta * (scrollDistance * scrollAmount));

                $('html, body').stop().animate({ scrollTop: finalScroll }, scrollSpeed, scrollEffect);
            }

            // Increase scroll amount
            scrollAmount++;

            // Clear current timeout
            clearTimeout(smoothScroll);
        }

        // Set animated scroll
        smoothScroll = setTimeout(function() {

            var delta = event.originalEvent.wheelDelta / 120 || -event.originalEvent.detail / 3;
            var scrollTop = $window.scrollTop();
            var finalScroll = scrollTop - parseInt(delta * (scrollDistance * scrollAmount));

            // Reset scroll amoount
            scrollAmount = 1;

            $('html, body').stop().animate({ scrollTop: finalScroll },
                (scrollSpeed*scrollAmount),
                scrollEffect
            );

            // Clear timeout holder
            smoothScroll = null;

        }, 100);

    });

}


#16

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.