簡體   English   中英

Javascript:將值從子頁面分配到父頁面

[英]Javascript: Assign value from the child page to parent page

我使用以下腳本創建了一個彈出窗口。

var CarricularWindow = window.open(“ AddCarriculars.aspx”,“ Extra Carriculars”,“ height = 200,width = 200”);

此彈出窗口包含一個TextBox和一個按鈕。 現在,當用戶在該文本框中輸入一些數據並單擊按鈕時。 我希望將數據復制到調用頁面上的TextBox中。

我該怎么做?

您可以在調用窗口中定義一個javascript函數:

function setText(text) {
    document.getElementById('yourtextboxid').value = text;
}

並在彈出窗口中,當用戶單擊按鈕時:

var text = document.getElementById('someothertextboxid').value;
window.opener.setText(text);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM