Reputation: 53
I've tried looking around for an answer to this and tried many variations of window.location.reload
although to no avail.
What I have the user doing is, they press a button to create a date which should then refresh the page as soon as it's been confirmed to then show the new date on the home screen.
This works on any browser I've tried (Chrome, Edge, Firefox, Opera) on the desktop although when it comes to mobile devices, the results are quite random.
I've tried this on;
Here is the code for the button
<div class="row">
<div class="col col-xs-12 form-group ">
<button onClick="window.location.reload();" type="button" class="btn form-btns btn-primary" id="submit_btn" title="Submit Data" data-placement="bottom" >
<i onClick="window.location.reload();" id="submit_check_icon" class="fa fa-send "></i> Save
</button>
</div>
</div>
Any idea on what the cause of this behaviour could be?
If I've missed any vital information out, please let me know and I'll revise my question.
Upvotes: 1
Views: 4924
Reputation: 3537
window.location.reload
works with all browsers and there are no known issues with it.
The problem might be that your browser is displaying cached data.
The window.location.reload
accepts a parameter forcedReload
Is a Boolean flag, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.
If this is not the case, then you can force the refresh in another way like
history.go(0);
or location.href = location.href;
Upvotes: 2