Enabling your SharePoint page to refresh automatically after x seconds is as simple as adding a Content Editor web part and adding the following javascript to it in the source editor:
<script type="text/javascript" language="javascript">
var reloadTimer = null;
var sURL = unescape(window.location.pathname);
function setReloadTime(secs)
{ if (arguments.length == 1)
{ if (reloadTimer) clearTimeout(reloadTimer);
reloadTimer = setTimeout("setReloadTime()", Math.ceil(parseFloat(secs)*1000));
}
else
{ reloadTimer = null;
location.reload(true);
window.location.replace( sURL );
}
}
setReloadTime(30);
</script>
This script will reload the page ever 30 seconds. In order to hide the web part from the view on the page, set the following properties:
Height: 0px
Width: 0px
Chrome Type: none
Under advanced uncheck all advaanced properties.
That should do it...now your SharePoint page will auto-refresh every 30 seconds.
Good Luck...
you're missing a slash from the script close tag. cheers though.
ReplyDeleteThanks for catching my typo.
ReplyDeleteEvery time it attempts to refresh, a dialog box appears telling me that IE needs to resend the information with buttons to 'retry' or 'cancel'...any way around this?
ReplyDeleteEvery time it attempts to refresh, a dialog box appears telling me that IE needs to resend the information with buttons to 'retry' or 'cancel'...any way around this?
ReplyDeleteya, me too. Any help would be awesome!
What is happening is that the refresh is trying to post back form data again. You need to set the following:
ReplyDeleteremove
location.reload(false);
replace
window.location.replace...
with
window.location(sURL);
Let me know if this works for you.
Thanks a lot!
ReplyDeleteI changed location.reload(true);
to
location.reload(false);
and made the 2nd change
replace
window.location.replace...
with
window.location(sURL);
It works great, thanks for your help.
This works ok, but the problem is it makes my server run to a 100% everytime it refreshes.
ReplyDeleteBut is there a AJAX enabled refresh webpart for announcments available maybe ?
Thanks heaps for this.
ReplyDeleteTo get rid of the dialog box I had to change window.location.replace...
to
window.location=sURL;
and remove the location.reload line completely.
That did it!!
ReplyDeleteHad to change to:
window.location=sURL;
and remove the location.reload line completely.
This works but if I have a filter set on a column it resets the filter. Is there a way to keep the filter when it refreshs?
ReplyDeletebump for above question
ReplyDeletehi,
ReplyDeletei have created one webpart which shows slides for images.
My Sharepoint Page load first time at that time i m not able to see the slides in my webpart....so i need to do is that after first sharepoint page load.... i need to refresh only that webpart (slides) after 5 second of first load of whole page.
Is it possible for webpart.???
great post, thank you very much!!!
ReplyDeleteGreat post! I was looking for this one, although I'd had to adjust the original code with window.location=sURL to avoid the pop-up prompt on refresh.
ReplyDeletegreate post, but I have the sameproblem as anonymous, I ahve a webaprt on the apge that has a calendar and if I change the date, I would like to keep that date efter the refresh. anyonw got any idea?
ReplyDeleteI was having a problem with sorting being lost on the page refresh. What I did to fix that problem was just to change var sURL = unescape(window.location.pathname);
ReplyDeleteto
var sURL = window.location;
This preserves the sort since the sort variables are passed in the querystring.
Nice tip, if your page is _finished_. However, if you have a target usergroup allowed to edit the page, you will have a problem. Auto-refreshing a page in edit mode is, needless to say, extremely undesirable.
ReplyDeleteHi, this is a great post. . very helpful. but is there an AJAX enabled refresh webpart? I want my data to get refreshed every 30sec automatically but do not want that webpart/page to blink...
ReplyDeletePlease help...
This actually worked for me so I'm extremely grateful, half the blogs\posts on the internet about Sharepoint are rubbish and code snippets offered don't work so this makes a refreshing change...thank you.
ReplyDeleteHey guys is there any way to use ajax in it.. I am using this snippet alog with a performance point webpart to update the KPI webpart.....and if users settings like collapsed and expanded items also get reset to orignal value....i.e all expanded or all collapsed.....
ReplyDeleteI've been trying all you people posted and still had problems, finally i resolved it with this simple script
ReplyDelete< meta http-equiv="refresh" content="60" >
just added it into "source editor" and everything worked fine.
hmm... i just posted the script:
ReplyDelete< meta http-equiv="refresh" content="60" >
i've forgot to tell you ppl, to not forget to remove the space's between the " < " and " > "
=)
I am very new to all of this...I have a webpart that displays information from several another sources(printer/toner status) I would like to refresh the (printer/toner)status when a user loads the page, any ideas?
ReplyDeleteworks great, thanks!
ReplyDeleteBTW, setting it to 5 seconds to test is fun: on an old dev server it takes more than 5 seconds to get to the Source to change it!
I love the single line meta tag version - worked like a charm and doesn't consume much server cpu time.
ReplyDeletereceptor petra onwards tianzhong stocked holder revisited landfill doecke fragments generated
ReplyDeletesemelokertes marchimundui
Nice piece of information... thanks for sharing...
ReplyDelete