Use JavaScript to set, get values from parent-child pages

Source: Internet
Author: User

    • One: Gets the value from the parent page

There are two ways to Windows.open () and Windows.showmodaldialog ()

1.windos.open (Url,name,reatures,replace)

Fatherpage.aspx in the parent page

<script type= "Text/javascript" >

function A () {

Windows.open ("sonpage.aspx")

}

</script>

Gets the objects, values in the parent page (sonpage.aspx) in the child page

<script type= "Text/javascript" >

var Text=windows.opener.document.getelementbyid ("TextBox1"). Value;

Alert (text)

</script>

2.windows.showmodaldialog (Url,name,??,??,??)

In the parent page

<script language= "JavaScript" >
function Popwindow (){
window.showModalDialog (sonpage.aspx ', window);
}
</script>

get values in a sub-page

<script language= "JavaScript" >
var vwin = window.dialogarguments; Get window Parameters
var doc = vwin.document.getElementById ("TextBox1"). Value; Get the value of a textbox
Alert (DOC);
</script>

  • gets the value of the child page callback in the parent page

Use JavaScript to set, get values from parent-child pages

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.