65.9K
CodeProject 正在变化。 阅读更多。
Home

从子窗口调用父窗口的 JavaScript 函数的方法。

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (1投票)

2013 年 10 月 11 日

CPOL
viewsIcon

58723

大家好,我将在这里解释如何从子窗口(弹出窗口)调用父窗口的 JavaScript 函数。有些人可能在阅读本文之前就已经知道。

您好,

我将在这里解释如何从子窗口(弹出窗口)调用父窗口的 JavaScript 函数。

有些人可能在阅读本文之前就已经知道。

父窗口 JavaScript 函数:

<script language="Javascript" type="text/javascript">

    function CallAlert()

    {

        alert("这是父窗口的提示函数。");

    }

</script> 

子窗口 JavaScript 函数

<script language="Javascript" type="text/javascript">

    function SetParentWindowsHiddenFieldValue()

<script language="Javascript" type="text/javascript">

    function SetParentWindowsHiddenFieldValue()

    {

        window.opener.document.getElementById("HiddenField1").value =

                            document.getElementById("TextBox1").value;

        return false;

    } 

  function CallParentWindowFunction()

    {

        window.opener.CallAlert();

        return false;

    }

</script>

© . All rights reserved.