javascript problem analysis on refreshing the parent page after the execution of the open.window child page

  • 2020-06-01 08:19:59
  • OfStack

This article analyzes the javascript method of refreshing the parent page after the execution of the open.window child page. Share with you for your reference. The specific analysis is as follows:

The main page:

<input id="btnAdd" type="button" onclick="openWin();" value=" add " />

In js we have the following code:

function openWin() {'addInfo.jsp', '_blank',
  // define callback Method for callbacks 
  function callback() {
// Refresh the current page 
function refreshWin() {
// Call the method to refresh the page, here RefreshSocket The corresponding method for refreshing the page 
// In other words, if the page has a refresh button, 
// Click the button to submit the class name is the class name here 
var url = 'RefreshSocket';
window.location.href = url;

On the addInfo.jsp page you have the following code:

<form name="form" action="AddSocket" method="get">
<input id="onSub" type="button" onclick="formSubmit();" value=" determine ">

function formSubmit(){
// submit action to AddSocket class 
// When the above execution is complete, the call to open the page callback Method, 
// Here is the main page of the call callback methods 
window.close();// Current page closed 

In addition, if it is an operation like delete, jump directly from 1 jsp to 1 class. After executing 1 series of operations in the class, if you want to refresh the current page, you can write the jump statement directly in the class, as shown below:

Main page mainPage.jsp:

// Delete the operation associated with the background DeleteSocket Class, if you want to pass a parameter, use ? Can be 
window.location.href = DeleteSocket

DeleteSocket class page:

// perform 1 After a series of operations, you can write directly JavaScript code 
// After writing this sentence, you can jump directly to the main page and refresh the main page
out.print("<script type='text/javascript'>location.href='mainPage.jsp'</script>");

I hope this article has helped you with your javascript programming.

Related articles: