主要是在父頁面使用 function PopupWindow() {
window.open(url, "", "status=no,resizable=no,toolbar=no,menubar=no,location=no,scroll=no,Width=600,Height=500");
}javascript
打開頁面java
而後在子頁面調用opener.document得到父頁面的document,而後將子頁面某個控件的值賦給父頁面控件url
父頁面server
<script type="text/javascript">
function PopupWindow() {
window.open("SearchUserWindowModel.aspx", "", "status=no,resizable=no,toolbar=no,menubar=no,location=no,scroll=no,Width=600,Height=500");
}
</script>ip
<asp:TextBox ID="txtParentTextbox" runat="server"></asp:TextBox>
<input type="button" value="Popup window" onclick="PopupWindow()" />get
子頁面input
<script type="text/javascript">
function ReturnValue() {
if (opener != 'undefined' && opener != null) {
//opener.document.getElementById("txtParentTextbox").value = document.getElementById("ddlCity").options[document.getElementById("ddlCity").selectedIndex].value;
opener.document.getElementById("txtParentTextbox").value = document.getElementById("ddlCity").options[document.getElementById("ddlCity").selectedIndex].text;
window.close();
}
}
</script>it
<asp:DropDownList runat="server" ID="ddlCity"></asp:DropDownList>
<asp:Button runat="server" ID="btnSeach" OnClick="btnSeach_Click" Text="查詢" />
<input type="button" value="Ok" onclick="ReturnValue();" />io