window.opener

建立一個共用的Child作為資料查詢頁面,當需要此Child頁面時,透過Parent頁面開啟Chile作為新分頁,在Child頁面將選擇的值回傳給Parent頁面。

imagewindow.opener

 

 Parent 頁面 

    <button type="button" onclick="openChild()">Open child</button>

   <script type="text/javascript">

        function openChild(){
            window.open('/Child/Query', '_blank', 'height=670,  width = 1400');
        };

        function receive(data) {
            console.log(data);
        }
    </script>

 

 Child 頁面 

   <button type="button" onclick="returnValue()">Go Back</button>

   <script type="text/javascript">

        function returnValue() {
            window.opener.receive("Test");  // 呼叫 Parent的receive function()
    };
    </script>

arrow
arrow
    文章標籤
    window.opener postback
    全站熱搜

    門外漢 發表在 痞客邦 留言(0) 人氣()