0

window.open() を使用して支払いダイアログを表示する Web サイトに問題があります。

ポップアップ内のページは、結果ページにリダイレクトされる別のドメインにリダイレクトされます。結果ページで、プロパティを on に設定しwindow.openerて、支払いが正常であることを示します。

これは一部のユーザーに有効です。ただし、他のユーザーには、それwindow.openerが未定義であるというエラーが表示されます。

この問題は、次の簡単なページを使用して再現できます。

index.html (ポップアップを開く)

<!DOCTYPE html>
<html lang="en">
<body>
    <input type="button" value="Popup" onclick="openPaymentWindow();" />

    <div id="result" style="background-color: silver;"/>

    <script type="text/javascript">
        function openPaymentWindow() {
            win = window.open('popup.html', 'popup');            
        }
    </script>    
</body>
</html>

popup.html (別のドメインにリダイレクト)

<!DOCTYPE html>
<html>
<body onload="document.forms[0].submit();">
    <form action="http://[other_domain]/payment.html">
    </form>
</body>
</html>

payment.html (元のドメインにリダイレクトします)

<!DOCTYPE html>
<html>
<body onload="document.forms[0].submit();">
    <form action="http://[original_domain]/result.html">
    </form>    
</body>
</html>

result.html (インデックス ページにプロパティを設定します)

<!DOCTYPE html>
<html>
<body>
    <input type="button" value="Call top" onclick="callTop();" />

    <script type="text/javascript">
        function callTop() {
            // Here, window.opener (and top.opener) is undefined for some users
            window.opener.document.getElementById('result').style.background = 'green';
        }
    </script>  
</body>
</html>

すべてのユーザーが影響を受けるわけではないため、何らかのセキュリティ設定に関係していると推測されます。しかし、どこでそれらを見つけるか、または自分のPCでエラーを再現する方法がわかりません。

4

1 に答える 1