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

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.