How to force a window reload in Service Portal?

Phil Swann
Tera Guru
Tera Guru
$window.location.reload() only works in chrome and not in IE
 
 
have tried:
location.reload(true);
window.location.href = window.location.href;


anyone else experienced the same or similar, and has anyone solved this?
4 REPLIES 4

Justin77
Mega Guru

The great thing about having access to AngularJS in the Service Portal is that the majority of the time we can manipulate the $scope and therefore don't need to worry about refreshing.  And while this does give our end users a better experience, I have come across times where it is necessary to reload the page.  That being said, I would first try to accomplish what you're attempting to do via $scope manipulation.  Here's a link to the documentation: https://docs.angularjs.org/guide/scope

 

And for some information as to why your original attempts did not work in IE/Edge: https://developer.mozilla.org/en-US/docs/Web/API/Location/reload (see browser compatibility section)

Matt Taylor - G
Giga Guru

Looks like this is a known issue with IE. They suggest building in a timeout to solve it. See link below:

https://hi.service-now.com/kb_view.do?sysparm_article=KB0717369

Phil Swann
Tera Guru
Tera Guru

Thanks both, will check and confirm back 

walemark
Kilo Explorer

The reload() function takes an optional parameter that can be set to true to force a reload from the server rather than the cache. The parameter defaults to false, so by default the page may reload from the browser's cache. The true parameter forces the page to release it's cache.

The window.location.reload() will reload from the server and will load all your data, scripts, images, etc. again. So if you just want to refresh the HTML, the window.location = document.URL will return much quicker and with less traffic. But it will not reload the page if there is a hash (#) in the URL.