Javascript Analysis on the Problem of refreshing the parent page after the execution of the open. window subpage is complete, and javascript refreshes the parent page
This article analyzes the javascript method for refreshing the parent page after the execution of the open. window subpage is complete. Share it with you for your reference. The specific analysis is as follows:
Home page:
<Input id = "btnAdd" type = "button" onclick = "openWin ();" value = "add"/>
The following code is available in js:
Function openWin () {window. open ('addinfo. jsp ',' _ blank ', 'width = 300, height = 400, top = 200, left = 400');} // defines the callback Method for callback function callback () {refreshWin () ;}// refresh the current page function refreshWin () {// call the method for refreshing the page. Here, RefreshSocket is the method for refreshing the page. // That is to say, if the page has a refresh button, // The class name submitted by clicking the button is the class name var url = 'refreshsocket '; window. location. href = url ;}
The addInfo. jsp page contains the following code:
<Form name = "form" action = "AddSocket" method = "get"> <input id = "onSub" type = "button" onclick = "formSubmit (); "value =" OK "> </form>
Function formSubmit () {this. form. submit (); // submit the action to the AddSocket class window. opener. callback (); // After the preceding execution is complete, call the callback method to open the page. // call the callback method window on the home page. close (); // close the current page}
In addition, if you want to delete an operation like this, you can directly jump from a jsp to a class. after performing a series of operations in the class, if you want to refresh the current page, you can directly write jump statements in the class, as shown below:
MainPage. jsp on the home page:
// The delete operation is associated with the DeleteSocket class in the background. If you want to transmit parameters, use? Window. location. href = DeleteSocket
DeleteSocket page:
Copy codeThe Code is as follows: // after performing a series of operations, you can directly write JavaScript code.
// After writing this sentence, you can directly jump to the home page and refresh the Home Page
Out. print ("<script type = 'text/javascript '> location. href = 'mainpage. jsp' </script> ");
I hope this article will help you design javascript programs.