How can I allow selections, but disable copying on a page?
Asked by Bob Jordan:

Hi,

I'd like to allow for a section of text to be selected (to allow for inline comments), but disallow it from being copied.

This page illustrates perfectly what I want to do: <https://codepen.io/herrberk/pen/yJJgJe>

Is there a way to implement that page's code for 'select but not copy' in confluence's CSS? I don't need the alert part, just the disable copy part.

\<p class oncopy="return false;" oncut="return false;" oncontextmenu="window.alert('Nice try! Even Ctrl+C or Ctrl+X will not work!');return false;"\>\<i\>You can select but can not copy me ;)\</i\>\</p\>


Answers:
author: Bill Bailey
body: I am with [@Marty](/t5/user/viewprofilepage/user-id/880798) , I am curious about your use model.

If you are trying to stop unscrupulous copying, it would probably be done by someone who is fully aware of the workaround. For example, with inspecting a page, you can just turn off those CSS rules. Or I can pay someone else to just quickly transcribe the content. If it is online, it can be copied.

If you have the space set to view-only for all users except admin, then you have done as much as you can to protect your content (plus a site-wide copyright statement). But at some point, you have to trust your users. Otherwise, you need to distribute your documentation via secured PDFs only, each one serial numbered, tracked and distributed under NDA. But even that will not protect you from the unscrupulous.

comments: author: Bob Jordan
body: Hi Bill,

Please see my response to Martyn above.

I realize that there will always be a way to copy the text if someone is determined enough, but I'd simply like to make it slightly more inconvenient to discourage certain behaviors.


author: Bill Bailey
body: Have you tried beatings? ;-)

Yes, weaning people of off Word is really hard. The issue you have is trying to disable the copy function but still allow the inline commenting (which requires the ability to highlight). So that means you cant use the CSS hack you showed to just disable the ability to highlght/select. You need to be able to implement the events:

```
oncopy="return false;" oncut="return false;
```

Which would need to be implemented on the main content container of the page:

```
<div id="main-content" class="wiki-content"> 
</div>
```

And that means you need to modify page layout. Which now is easier to do than before. Go to the admin console, Layouts under Look and Feel.

[customizing-site-and-space-layouts](https://confluence.atlassian.com/conf62/customizing-site-and-space-layouts-902074915.html)

Use with caution, actual mileage may vary.


author: Bob Jordan
body: Cheers Bill, thanks for that.

Unfortunately I don't have system admin privileges (I don't have the 'general config' -\> 'layouts' option.

Sounds like layout editing would be the only way to accomplish this? Is there anything you can think of that may be available in the "space tools" that would solve for this as well?

Otherwise I'll just need to find and bug the system admin :\|


author: Bill Bailey
body: Yeah, this is an admin only feature due to the far-reaching implications of changing these templates.


author: Bob Jordan
body: Ok, I'll have to bug them then. Thanks for the help with this one :)


author: Sneha Gole
body: hello, [@Bill Bailey](/t5/user/viewprofilepage/user-id/502089) i have made changes as you were list above in page layout. but i want to restrict copy for specific "space " only ..how to do that?


author: Marty
body: Hi Bob,

I am not from the Confluence team, but I will try to help.

In general trying to prevent people from copying content from a web page will not be 100% airtight. People can take screenshots. Or take photos with their phones. Or open up the developer tools, inspect an element, and copy the content that way.

The code you're trying to add to the page might fool some users but not all.

I wondered if you could share a little more about why you're trying to prevent users from copying some content and perhaps I can suggest a different way to use Confluence to achieve your goals?

comments: author: Bob Jordan
body: Hey Martyn,

Thanks for the response.

I understand that nothing is 100% secure and I'm not worried about this. I only want to put in road blocks and make the process inconvenient.

My use case is that we use confluence to review team documents. Some members outside of my team will copy and paste the contents of the page into a word document and send their review comments that way rather than commenting on the page directly (even though of course we've asked them not to). I'd like to discourage that behavior, so making the text selectable to allow for in-line commenting but not copyable should be sufficient.


author: Marty
body: Ahh that makes sense. That does sound frustrating!

Sorry to hear that. Let's see if the community can help you with a small CSS trick then.


Tags: css

html