Autorefresh SharePoint List Using JavaScript

Introduction

You want to create a List or Dashboard that will automatically refresh itself on a regular basis. Yes, this is easily accomplishable using a SharePoint Web Part and a little bit of scripting; JavaScript in this case, to be precise.
 
How to Accomplish This Task

Start by going to the page you want to edit and begin editing the page (you will obviously need to have rights to do this).

Editing the page

Add a Web Part to your page (you should already be in a mode as in the following).

add Web Part

Choose the "Media and Content" Category, "Content Editor" Web Part, and add it to any part of the page (such as the "Header").

Content Editor

Select the web part and choose "Edit Web Part" from the drop down. A menu will appear on the top right hand side of the page, you may need to scroll over/up to find it.

Edit Web Part

Set the Title to "Refresh the Web Page".

Refresh the Web Page

Set the Chrome Type to "None".

 Chrome Type

Click "OK" to accept those changes. Then you need to add the script to the web page. To do this, you start by clicking in the section "Click here to add new content".

add new content

A cursor will appear in the content area, however, don't type anything in the content area, instead simply go to the ribbon and under "Editing Tools" select "Format Text", select the HTML drop down, and choose "Edit HTML Source".

Edit HTML Source
 In the HTML Source box, enter the following JavaScript code.

<script type="text/javaScript">

function refreshPage() {

    window.location = window.Location;

}

setTimeout(refreshPage, 300000);

</script>
 
Basically, this script is calling a function every 5 minutes (1000 milliseconds * 60 seconds * 5 minutes = 300000; this can be any value you choose, just do the math right), that will refresh the page (without showing the annoying, "Are you sure you want to resubmit this page" message that appears in IE when using "window.location.reload").

Finally, stop editing the page and you will be all done.

stop editing

Conclusion

Now your list is refreshed every 5 minutes and you don't need to worry to see the updated data siince it's getting refreshed automatically.

Up Next
    Ebook Download
    View all
    Learn
    View all