How can we help you today?

How to Automatically Refresh the Page After Certain Period of Time

Content on your SharePoint page gets updated every time it refreshes or reloads. This happens when you first open the page on your browser or every time you manually refresh it.


If you have data on your SharePoint page that needs to be updated in real time, you may want to refresh your page automatically after a certain amount of time. This article will demonstrate how to implement the Javascript code that can automatically refresh your page after a certain period.


Here is how it will look like:


automatically refresh page


TABLE OF CONTENTS


Prerequisites

  • You must have the latest version of ShortPoint SPFx installed on your SharePoint environment.
  • You must be a ShortPoint Designer with an active license.

Step-by-step Tutorial

Follow the steps below to learn how to add a Javascript code that will automatically refresh your page:


Step 1: Edit the ShortPoint Web Part

Go to the SharePoint page you want to use and click Edit:

Edit

Click the ShortPoint tag:


ShortPoint tag


Select the pencil icon:


pencil icon


Step 2: Insert the Code Design Element 

Click the plus icon:


plus icon


Use the search bar to look for Code and select it:


Code


Step 3. Copy the JavaScript code

Copy the Jave Script Code below:

setTimeout(
    function() { window.location.reload() },

    seconds(2) // <= only change this line, possible values are the following
    // seconds(number)
    // minutes(number)
    // hours(number)
    // days(number)
    // example: minutes(15) will make the browser refresh every 15 minutes
)


/**
 * do not touch beyond this point
 * utility methods
 */

function seconds(digit) {
  return digit * 1000;
}

function minutes(digit) {
  return seconds(digit) * 60;
}

function hours(digit) {
  return minutes(digit) * 60;
}

function days(digit) {
  return hours(digit) * 24;
}

Step 4:  Paste the copied code

Paste the code in the Javascript field:


JavaScript field


Change the seconds(2) value according to your preference:


change seconds(2)



NOTEYou can also replace seconds(number) with minutes(number), hours(number), days(number). For example, minutes(15).


replace seconds(number)



Step 5: Disable Sandbox Mode

Navigate to the Design tab:


Design Tab


Disable Sandbox Mode:


Sanbox mode


Once done, click the green check mark:


green check mark


Step 6: Save


Click Save to apply all your changes: 


save


That's it! Now,  your page will automatically refresh after the time you set.


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 74 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more