Javascript location reload function of DOM window object provides the functionality to reload or refresh the current web page. You can create function having the code to run the location.reload function onclick event of button control or any other HTML element that supports mouse events to call Javascript function. Location reload function refreshes the currently open web page. Do not place the window.location.reload() function openly in the Javascript block placed in the HTML <head> section of HTML document. It will set it into infinite loop of redirecting the same page at its own URL on page load coz each time when page will load. It will fire the location.reload function causing the infinite loop of reloading the same URL again and again.

Syntax of Javascript Window Location Reload or Refresh Function

location.reload();

or

window.location.reload();

Both code syntax to reload or refresh the current page using window object or without window object will work similarly.

Example of Javascript Window Location Reload or Refresh Function

<script type="text/javascript" language="javascript">
    function reloadURL() {
        window.location.reload();
    }
</script>

Call the above reloadURL() function onclick event of button control:

<input
    type="button"
    value="Refresh Location URL"
    onclick="reloadURL();" />

Continue to next tutorial: Javascript Window Location Href URL to learn how to redirect the get or set the current URL using JavaScript.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.