Today I wrote a small page that prompts success. It also requires returning to the previous page and refreshing the operations on the previous page (such as deletion and addition). I searched it online and found that basically 90% of the results are correct. It means using window.history.go(-1), or using window.history.back(-1), and some say that the child page refreshes the parent page.
Copy the code code as follows:
<script language=JavaScript>
self.opener.location.reload();
</script>
After testing on the JSP page, after clicking the button to save the added items on the operation page and then jumping to the success prompt page, I found that they were not refreshed and were displayed after manual refresh. It is really difficult for those articles whose paste and copy technology have not been tested. It's heartbreaking.
In fact, I have not found a way to completely rely on JS for this technology. One idea is to prevent the previous page from being cached and just read it out every time (I don’t understand the specific principles of other people’s ideas).
The implementation method of JSP is as follows:
Reply-text mb10 code
Copy the code code as follows:
<SPAN style="FONT-SIZE: 18px; BACKGROUND-COLOR: #ffffff">
<SPAN style="FONT-FAMILY: 'Microsoft YaHei'; COLOR: #3333ff">
<STRONG>
<%String rec = request.getHeader("REFERER");%>
<input type="button" onclick="javascript:window.location='<%=ref%>'">
</STRONG>
</SPAN>
</SPAN>
<%String rec = request.getHeader("REFERER");%>
<input type="button" onclick="javascript:window.location='<%=ref%>'">
The implementation method of ASP page is as follows:
Copy the code code as follows:
<%'Get the address of the previous page
address = request.ServerVariables("HTTP_REFERER")
%>
<!--window.location has the function of returning relative pages and refreshing them-->
<a href="javascript:window.location.href='<%=address%>'" style="cursor:hand">Return</a>
Reply-text mb10 code
Copy the code code as follows:
<SPAN style="FONT-SIZE: 18px; BACKGROUND-COLOR: #ffffff"><SPAN style="FONT-FAMILY: 'Microsoft YaHei'; COLOR: #3333ff"><STRONG>. in servlet
request.getRequestDispatcher(request.getHeader("referer")).forward(request,response);
or
request.getRequestURL();
</STRONG></SPAN></SPAN>