How to Add Refresh Page Buttons, Links

Do you want to add a refresh page button or reload page link to the HTML of the web page? This might be useful for purposes when you are live blogging, posting newsy contents in real time or engaging in a quick discussion on quick blogging themes. This would enable users to just click the button and reload rather than repeatedly hitting the browser refresh icons.

refresh page

1. Javascript Page Refresh Link

The easiest way would seem to link to the permalink of the page, and clicking it will simply revisit the page again. But then the next methods are independent of links added to the code.

The simplest way is to use a javascript link and it looks like this. This will create a link and clicking it will simply reload the page of the current url as visible in the browser url field.

<a href="javascript:location.reload();" >RELOAD PAGE</a>

2. Javascript Refresh Page Button

If you prefer to display this code as button, use the input tags and a button will appear instead of a link.

<input type="button" value="Reload page" onclick="location.reload();"> 

Its easy to add classes to style the links and buttons as per your site design. Just add CSS style to the class ‘yourstyle’ and get an amazing number of options. If you are using CSS frameworks like Bootstrap, there are easy to use btn classes for styling.

<a class="yourstyle" href="javascript:location.reload();" >RELOAD PAGE</a>

3. Refresh and Reload Page Button

If you do not want to add the scripts in the html body, then another way is to put the script in the HEAD part of the HTML code like this

<script>
function reloadPage()
{
location.reload();
}
</script>

The use of input tags to create the buttons as needed. Click to refresh the page.

<input type="button" value="Reload page" onclick="reloadPage()">

4 Auto Refresh Pages

Use this with care as such pages will continue to auto refresh is left alone in a browser window and can affect page traffic statistics. This might also not be good for SEO and search engine data as it might be seen as an attempt to artificially increase pageviews.

You can force reloading of pages after selected time intervals using META refresh tags. In the example below, the page will refresh every 30 seconds.

<META HTTP-EQUIV="refresh" CONTENT="30">

If the url is fixed, the you can add the urls link also to the page

<META HTTP-EQUIV="refresh" CONTENT="30" URL="http://domain.com/">

Read more tips about

Start a discussion. Share your view: Post a Comment on Twitter