Reload page in js: RefreshPage
By Anatoly Mironov
There are many ways to reload / refresh a page in javascript. One of them is as in discoveringsharepoint.wordpress.com describes:
window.location.reload()
```Today I found some tools which are shipped with ASP.NET/SharePoint to reload a page. The big advantage of them they are designed to work with SharePoint and take all possible aspects of page life cycle into account. The javascript function to refresh a page is just called, guess..: **RefreshPage** and it resides in init.js:
//init.js: function RefreshPageTo(evt, url, bForceSubmit) {ULSA13:; CoreInvoke(’_RefreshPageTo’, evt, url, bForceSubmit); }
[![](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-001.png "refresh-page-001")](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-001.png) It takes at least one parameter, the dialogResult: [1, 0 or -1 which are SP.UI.DialogResult.OK or SP.UI.DialogResult.cancel or SP.UI.DialogResult.invalid](http://msdn.microsoft.com/en-us/library/ff409060.aspx "See SP.UI.DialogResult Enumeration on msdn"). [![](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-004.png "refresh-page-004")](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-004.png) [![](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-002.png "refresh-page-002")](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-002.png) The only thing it does is to invoke a function from core.js:
//core.js: function _RefreshPageTo(evt, url, bForceSubmit) {ULSrLq:; return _SubmitFormPost(url, bForceSubmit); }
[![](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-003.png "refresh-page-003")](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-003.png) The \_RefreshPage function from core.js validates the data and invokes \_SubmitFormPost: [![](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-005.png "refresh-page-005")](https://sharepointkunskap.files.wordpress.com/2012/01/refresh-page-005.png) In the end it gets the main form ("aspnetForm") and invokes submit on it:
document.forms[MSOWebPartPageFormName].submit()
## Comments from Wordpress.com
####
[discoveringsharepoint](http://discoveringsharepoint.wordpress.com "johannesmilling@hotmail.com") - <time datetime="2012-01-11 09:27:29">Jan 3, 2012</time>
Great post. I'm sure to try this the next time I need to call a page refresh. =)
<hr />