Disable attachments download, export, print and other functions in specific spaces

Recently, some teams using Confluence have put forward more advanced requirements for information confidentiality.

These space administrators want to prohibit users from downloading, exporting, and printing attachments in designated spaces.

Last week, I checked a lot of related setting posts in the community. According to the community’s suggestions, I adjusted the space configuration for your reference.

Hide the download button on the preview page

Space Tools--Look and feel--Layout--Content Layouts---Page Layout

<style type="text/css">
     
.cp-control-panel-download {
        
display:none !important;
    
}
 
      .cp-waiting-message-download {
        
display:none !important;
    }
      a.download-all-link {
        
display: none !important;
     
}
      a#download-all-link {
        display: none !important;
     
}
 
</style>

 

Hide attachment button

Space Tools--Look and feel--Layout--Content Layouts---Main Layout

#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name))
#else
    
<script type="text/javascript">
    
AJS.toInit(function(){
        
AJS.$('#view-attachments-link').hide();
        
AJS.$('#view-in-hierarchy-link').hide();
        
AJS.$('#content-metadata-attachments').hide();
    
});
</
script>
#end

#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name))
#else
    <script type="text/javascript">
    
AJS.toInit(function(){
AJS.$('#space-tools-menu-trigger').hide();
    
});
</
script>
#end

 

disable right mouse click

Space Tools--Look and feel--Layout--Content Layouts---Page Layout

<script type="application/javascript">
 content_dom = document.getElementsByClassName("confluence-embedded-file");
 
for (var i = 0; i < content_dom.length; i++) {
content_dom[i]
.oncontextmenu function () {
return false;
 
}
}
a_dom
 document.querySelectorAll('a[data-linked-resource-type="attachment"]')
for (var i 0; i < a_dom.length; i++) {
a_dom[i]
.oncontextmenu function () {
return false;
 
}
}
</script>

 

print out a blank page

Space Tools--Look and feel--Layout--Content Layouts---Page Layout

 <style type="text/css" media="print">
body { visibility: hidden; display: none }
</style>

 

Tips

https://confluence.atlassian.com/confkb/how-to-hide-the-space-tools-menu-for-anonymous-users-in-confluence-816877024.html

https://confluence.atlassian.com/confkb/how-to-hide-elements-in-confluence-using-css-or-javascript-313458894.html

https://confluence.atlassian.com/confkb/how-to-disable-attachment-downloads-215484007.html

https://community.atlassian.com/t5/Confluence-questions/Hide-items-in-option-menu/qaq-p/920803

https://community.atlassian.com/t5/Confluence-questions/Disable-CTRL-P-function-Prevent-Printing/qaq-p/1050179

https://stackoverflow.com/questions/6647392/how-to-stop-user-from-printing-webpages-using-javascript-or-jquery

 

5 comments

David May 28, 2021

Many thanks for this!  This is extremely useful. Exactly what I was looking for. 

I have tried the above and it works well. There is one exception though:

When you preview the file, you can still right-click and "save as..." which bypasses the whole setup.

Like Ollie Guan likes this
hohoha xu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 24, 2021

Good job, I disabled attachment download successfully with some little amendments on this article.

Like Ollie Guan likes this
Alex Gallien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2022

Really appreciate this post! Saved us a ton of time trying to track down all the right things to hide.

Like Ollie Guan likes this
Ollie Guan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 13, 2022
Mario Rosales
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 1, 2022

is this available using Cloud?

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events