JS Parent-child window value and the current page in the JS foreground how to get URL parameters

Source: Internet
Author: User
Tags id3

1. First, the parent page opens the window with window.open

<%@ page language= "C #" autoeventwireup= "true" codebehind= "WebForm3.aspx.cs" inherits= "WEBAPPLICATION17.WEBFORM3" %>

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

<title></title>
<script type= "Text/javascript" >

function Openchild () {

var k = window.open (' webform2.aspx?id=110&id1=120&id3=130 ', ' newwindow ', ' height=100,width=400,top=0,left=0 , Toolbar=no,menubar=no,scrollbars=no, Resizable=no,location=no, Status=no ');
window.showModalDialog ("/webform2.aspx", "obj", "dialogwidth:335px;status:no;dialogheight:300px");

}

</script>
<body>
<form id= "Form1" runat= "Server" >
<div>
<input type= "text" id= "txt10" name= "txt10"/>
<input type= "text" id= "Txt9" name= "Txt9"/>
<input type= "text" id= "txt11" name= "txt11"/>
<input type= "button" id= "Btn1" name= "BTN1" value= "Submit" onclick= "Openchild ()"/>

</div>
</form>
</body>
2. This is a sub-page

<%@ page language= "C #" autoeventwireup= "true" codebehind= "WebForm2.aspx.cs" inherits= "Webapplication17.webform2" %>

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

<title></title>
<script type= "Text/javascript" >
Window.onload = function () {

var k = Window.opener;
document.getElementById ("Txt1"). Value = K.document.getelementbyid ("txt10"). Value;
var url = location.search;
if (Url.indexof ("ID3")!=-1) {
Alert ("URL id3");
}
var therequest = new Object ();
if (Url.indexof ("?")! =-1) {
var str = URL.SUBSTR (1);

STRs = Str.split ("&");
for (var i = 0; i < strs.length; i++) {
Therequest[strs[i].split ("=") [0]] = (strs[i].split ("=") [1]);
}
}


};

function Setfather () {

Passing values to the parent window space
var k = Window.opener;
K.document.getelementbyid ("Txt10"). Value =
document.getElementById ("Txt1"). Value;
}
Sets the value returned to the parent window
function Retrunvalue () {
var s =
document.getElementById ("Txt2"). Value;
Window.returnvalue = s;
Window.close ();
}
</script>
<body>
<form name= "abc" runat= "Server" >
<input type= "text" id= "txt1" name= "Txt1"/>
<input type= "text" id= "txt2" name= "Txt2"/>
<input type= "button" id= "Btn1" name= "BTN1" value= "Submit" onclick= "Setfather ()"/>
</form>
</body>

JS Parent-child window value and the current page in the JS foreground how to get URL parameters

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.