You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello everyone,
We had the request from a group of users to have a dashboard-type page reload periodically, so that they can see changed content.
Based on a really old post here (https://community.atlassian.com/t5/Confluence-questions/Page-auto-refresh/qaq-p/306485), I have come up with a simple user macro that puts in a piece of javascript that essentially hooks up a setTimeout() function to the window.onload event, which in turn calls a page reload (code: see below).
The macro has the desired effect, but when you enter page edit mode, it triggers the reload once more while already in edit mode. This is not desirable, and I am unclear as to why this happens - my understanding is that the window.onload() functions would not be executed as soon as the edit page is loaded, as the macro is not active there.
I am admittedly not an expert in the inner workings of Confluence, can anyone point me into the right direction as to how I can fix the behavior to only cause reloads when the page is in viewmode?
Many thanks in advance,
Michael
User macro:
## Based on the discussion in https://community.atlassian.com/t5/Confluence-questions/Page-auto-refresh/qaq-p/306485
## Auto Refresh Wiki Page
## @param interval:title=Intervall|type=string|required=true|default=60|desc=Interval in seconds between triggered page reloads. Don't set this too small, otherwise you will put load on the server.
<script language="javascript">
// Assign an anonymous function to the onload event
window.onload = function(){
// The time out value is set to be $paraminterval seconds
setTimeout(' document.location=document.location' , $paraminterval * 1000);
}
</script>
The below script example hooks into the events that are fired when entering into edit mode. So you would need to change your code a bit to turn off the reload when these events fire off.
AJS.toInit(function () { //Launch if edit button clicked AJS.bind('init.rte', function (a, e) { AJS.$(e.editor.getWin().parent.document).bind("mode-changed", function () { // code to turn off page reload goes here }); AJS.$(e.editor.getWin().parent.document).bind("iframeAppended", function () { // code to turn off page reload goes here }); }); });
Hi Davin,
Thanks a bunch - this was the help I needed.
One remark: I was't able to get it to de-register (using clearTimeout()) the refresh when the code was within the nested bind() calls - but putting the code directly into the function that is bound to the 'init-rte' event worked.
Many thanks,
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.