Script Fragments
Script Fragments allow you to customize your Confluence instance. Learn about the two types and thier functionality.
There are two types of fragments that you can use to customize your Confluence instance:
Web item fragments
Using ScriptRunner for Confluence Cloud, you can add a button to a specific location in the UI. When users select ScriptRunner Action, a popup with the button appears.
Here is an example of a simple button directing users to more information in the Confluence Cloud UI:
Use cases
You could use custom buttons in a number of ways, here are a few ideas to get you started:
- Direct users to a log in or documentation page
- Open a Jira instance with project information related to the Confluence page, like the open tasks of a devlopement team
- Redirect users to another location within Confluence
- Give users a link to more resource information
Create a web item fragment
Follow these steps to create a custom button for your Confluence instance:
Here is an example of the web item form filled out:
Your custom button now appears in the spaces you specified.
Web panel fragments
The web panel script fragments can be used to add HTML snippets to parts of a page so you can display additional information.
Here is an example of a web panel display with an external source:
Use cases
You could use custom web panels in a number of ways, here are a few ideas to get you started:
- Add a banner to a documentation site to alert users of an important feature update
- Add resource information to a Confluence page
Create a web panel script fragment
Follow these steps to create a custom web panel for your Confluence instance:
Here is an example of the web panel form filled out:
Host URLs for script fragments
The HTML, CSS and JavaScript need to be hosted somewhere that Confluence Cloud servers can access with no authentication. We recommend using CodePen for the hosting. It's also important to note that the hosting must serve the correct content-type header for each file.
You should be aware that you may need to purchase the Pro version of CodePen in order to use this as a host. As a workaround, you could use codesandbox and create a static template. From there, create the JS, CSS and HTML files, access Script Fragments and complete the corresponding text boxes by using the codesandbox URL followed by /fileName.js (JS) /fileName.css (CSS) /fileName.html (HTML).
Adaptavist Bridge
The Adaptavist bridge is a JavaScript library that allows the script to do two things:
- Get space and page information
- Use Confluence REST APIs
Learn more about what it is and how to use it with the Adaptavist Bridge documentation.
Limitations
Functionality could be limited for security issues. If there is a security issue in code, the fragment will not render or redirect the user.
More resources
Visit the following Atlassian documentation pages to learn more about fragments: