JavaScript pops up the subform and returns the result to the parent form's implementation code _jquery

Source: Internet
Author: User

idea: Use the window.showModalDialog method to get the reference to the pop-up subform, and then return the result with window.returnvalue= "* *" on the child page.

Sample code: (Simplifies implementation with jquery)

Parent page: parent.html

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
 
 

Sub-page son.html

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Summarize:

parameter passing:

1. To pass the parameter to the dialog box, it is passed through varguments. Type is not restricted, for a string type, the maximum is 4,096 characters. You can also pass objects, for example:
-------------------------------

Parent.htm

<script>
     var obj = new Object ();
     Obj.name= "51js";
     window.showModalDialog ("son.htm", obj, "dialogwidth=200px;dialogheight=100px");
</script>

Son.htm

<script>
     var obj = window.dialogarguments
     alert ("The parameter you passed is:" + obj.name)
</script>

2. You can return information by Window.returnvalue to the window that opens the dialog box, or you can also be an object. For example:

Parent.htm

<script>
     str =window.showmodaldialog ("son.htm", "dialogwidth=200px;dialogheight=100px");
     alert (str);
</script>

Son.htm

<script>
     window.returnvalue= "http://blog.csdn.net/a497785609";

Extended:

In. NET, you can achieve AJAX effects in this way. When the subpage passes the parameters to be selected, the parent page implements the ICallbackEventHandler interface and passes the acquired value directly back to the server side. Or use the UpdatePanel Load event to catch the passed parameters, so as to continue the server-side processing.

Above this JavaScript pop-up subform and return the results to the parent form of the implementation code is small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.

Related Article

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.