On a Confluence page, I'm attempting to put in some Javascript code into an HTML macro.
<script type="text/javascript"> document.write(AJS.Meta.get("user-display-name")); </script>
Upon saving the page, it loads it correctly and shows my username. The problem however is when I attempt to Edit the Confluence page again. It won't let me edit the page any more. Instead of loading the page in Edit mode, it only shows my username in the browser window and it seemingly keeps loading the page.
Why would such a simple Javascript snippet cause such behavior?
Hello there Pieter!
I was able to replicate the behaviour you noted! I was also able to workaround it by two methods:
- Clicking the back button in the browser
- Opening the edit mode in another tab
If you are running a Confluence Server instance, you can create a user macro to achieve this:
1- Click the Cog Icon in the upper right corner
2- Search for User macros in the left hand panel
3- Select to Create a new User macro
4- Define Macro name and Macro title
5- Set Macro Body processing to Escaped
6- Insert the following in the template field:
## @noparams
$action.authenticatedUser.name
$action.authenticatedUser.fullName
7- Save the macro
8- Inser the macro in a page
9- It should display the Name and Full Name for the current user
*You can remove either FullName or name but not both.
Fur further information on this, you can check this documentation:
Pieter, let us know if this helps your objective!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.