On clild window close cannot send value to parent

2019-08-08 10:55发布

问题:

I need to open a new popup window/tab using window.open method of javascript and on close of the new tab/popup window have to return some values from closing window to parent window. When I open a popup suing window.open in my asp .net application which is supposed to be compatible with iPad. Value has successfully been returned when I use IE, Chrome, FireFox and Safari (on PC with windows 7).

Unfortunately the same code fails in Safari when I access the application through iPad. On iPad domObject is prompted on new window open instead of prompting returned value on new window close.

Below is the code. Parent Window:

    <script type="text/javascript">

        function modalWin() {       
                retVal = window.open('About.aspx', 'name', 'height=255,width=250,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no ,modal=yes');
                alert(retVal);
        }
    </script>
//HTML
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<a title="Test New Popup" onclick="modalWin();">New Popup for all browsers.</a>.
</asp:Content>
Popup window or new tab:

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

    //HTML:
<input id="btnButton1" value="btnButton1" type="button" onclick="closeIt('btnButton1');" />
<br />
<input id="btnButton2" value="btnButton2" type="button" onclick="closeIt('btnButton2');" />
<br />
<input id="btnButton3" value="btnButton3" type="button" onclick="closeIt('btnButton3');" />