Refresh page using javascript not working
Solution 1
The reload
method may use the cache to reload the page. Specify the force parameter to make it get the page from the server:
window.location.reload(true);
Solution 2
parent.window.location.reload(true);
worked on chrome for me ... finally
explanation: of parent.window
A reference to the parent of the current window or subframe.
If a window does not have a parent, its parent property is a reference to itself.
When a window is loaded in an , , or , its parent is the window with the element embedding the window.
Related videos on Youtube
Purav Shah
Updated on June 04, 2022Comments
-
Purav Shah almost 2 years
I send a post request to the server, which inturn returns a JSP. Now if i use the refresh button of the browser, i get a confirmation to resubmit the data, and then the page reloads successfully.However, when i try to refresh the page using javascript, i dont get any confirmation box, and the reload also doesnt work. Ive tried all methods of reload like :
- location.reload()
- window.location.reload()
- window.location.href = window.location.href
- history.go(0);
I think the problem is that its sending a get request when i try to refresh using javascript, and it is not able to find the necessary paramaters.
This problems occurs only in chrome... it works in Firefox and IE!!
-
c69 over 12 years
-
Purav Shah over 12 yearsThe problem is this: i submit a form on page 1. It takes me to page 2. now when im on page 2, if i click on browser's reload, then page 2 refreshes successfully (after getting a confirmation). However, if i put a this:
<a href="javascript:history.go(0);">Reload</a>
on page 2, and if i click on it, then i cant reload the page, since it doesnt send the necessary params of page1 form. My question is that is it possible to implement the same functionality of browser's reload button? -
Oskar over 10 yearsThanks for the explanation!
-
Jacob Lee over 3 yearsforce parameter is deprecated
-
Rehmat about 3 yearsAdding a random key to the page link should do the trick. The point is that browser will not reload until page link is changed.