當(dāng)前位置: 首頁(yè)IT技術(shù) → 動(dòng)態(tài)窗口中子頁(yè)面向父頁(yè)面?zhèn)鬟f值

動(dòng)態(tài)窗口中子頁(yè)面向父頁(yè)面?zhèn)鬟f值

更多

題目:在父頁(yè)面中,點(diǎn)擊“編輯”鏈接,跳至子頁(yè)面中進(jìn)行編輯,編輯完成后點(diǎn)擊“確定”,子頁(yè)面關(guān)閉,將編輯內(nèi)容回傳至父頁(yè)面。

原理:在父頁(yè)面中,點(diǎn)擊“編輯”時(shí),設(shè)置一個(gè)變量,此變量用于打開(kāi)子頁(yè)面新窗口,也用于接收子頁(yè)面的返回值;在子頁(yè)面中,設(shè)置一個(gè)函數(shù),完成返回傳遞值和關(guān)閉窗口的工作。

父頁(yè)面代碼:

<body>

 <a href="#" s= window.showModalDialog('b.html');s_Context1.innerHTML = s">編輯</a>

</body>

 

子頁(yè)面代碼:

<body>

<div id="edit-text">
            <form id="search" method="get">
            <!--action="/search.php"-->
            <input type="text" id="txt_Context" name="firstname" style="width: 640px; height: 400px;" />
            <input type="button" value="確定" style="margin-left: 300px;" onclick="ReturnValue(txt_Context.value)" />
            </form>
</div>

</body>

 

<script type="text/javascript">
        function ReturnValue(a) {
            window.returnValue = a;
            window.close();
        }

</script>

 

熱門評(píng)論
最新評(píng)論
發(fā)表評(píng)論 查看所有評(píng)論(0)
昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過(guò)審核才能顯示)