The key is to find the right element(s?) to replace .rich-text. So if you have a page to share or find something which seems relevant to you in the inspector…
Thanks Matthieu ! Can I replace .rich-text with the css tag? Just tried with this one and not working. In the inspector its select all the rich text field. Not live in my demo app sorry but I can try to share a demo app (app alive isn’t public until now)
<script>
const elements = document.querySelectorAll('.css-xxxx');
elements.forEach(element => {
element.addEventListener("contextmenu", function(event) {
event.preventDefault();
});
});
</script>
Or this one
<script>
document.querySelectorAll('.css-xxxx').forEach(function(element) {
element.oncontextmenu = function() {
return false;
};
});
</script>
Should be in the header custom code
Though I’m a little confused to know if const “elements” is ok…
Also it depends on the number of rich text elements who has the same class, as css-1cmeorz can appear multiple times, like buttons of a cta (or maybe not)…
@dcoletta I want a very special product, which corresponds to a platform that pays for access to pdfs. I want to allow my users to preview the content in a web way, I would like to be able to prevent from copy paste too easy. I know that the content will not be completely protected, but already if I make the task more difficult for new users it is a good thing
Again, tell me to stop if this isn’t helpful, but I would strongly suggest a different strategy. For example, remove every 10th word, or insert random text, or something. But trying to make your user not be able to do something for which they might have a totally legitimate purpose — for example copying and pasting to share with the person approving the purchase — is not only ineffective but also reduces likelihood of conversion (in my humble opinion).
Are you sure you don’t want to share a screenshot of the block where the rich text field appears? You can hide labels if you want, I just want to reproduce it on my end, then I will be able, hopefully, to get the right element. That way you won’t have to use an Iframe.
Or describe me the block you use, what are the fields inside of it.
Here is a code that may work:
Replace “myIframe” by the id of your iframe (“iframeMobile”)