[英]Access parent page variable from child page?
我想將一個子頁面的值傳遞給我的父頁面:
父頁面腳本:
<script type="text/javascript">
var popup;
function SelectName() {
popup = window.open("SelDestination.aspx", "Select", "width=500,height=300");
popup.focus();
return false;
}
</script>
在子頁面上:
<asp:Button ID="btnSelect" runat="server" CssClass="button" Text="انتخاب" OnClientClick="SetName();" />
子頁面腳本是:
<script type="text/javascript">
function SetName() {
if (window.opener != null && !window.opener.closed) {
var ddlName = window.opener.document.getElementById("txtDes");
//var e = document.getElementById("<%=ddlOffice.ClientID %>");
ddlName.value = "Hi";
}
window.close();
}
但這不能正常工作(我遇到運行時錯誤:ddlname為null或未定義)!
關於如何解決的任何想法?
制作一個javascript文件,並在頭部執行此操作:
<script src="path/to/ye/js"></script>
並記住要在兩個站點中都這樣做。 然后將此變量添加到javascript文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.