我正在使用带灯箱的 PayPal 嵌入式支付流程:
https://developer.paypal.com/docs/classic/adaptive-payments/integration-guide/APIntro/
付款完成后,用户将被定向到成功 URL。在成功 URL 上,我有一个脚本应该用成功 URL 的内容替换顶部窗口的内容:
https://developer.paypal.com/docs/classic/express-checkout/digital-goods/ClosingWindow/
我的代码如下:
$(document).ready(function(){
if (window != top) {
top.location.replace(document.location);
}
})
这在 Chrome、Opera 和 Firefox 中效果很好。问题是在 IE 11 和 Edge 中,PPDG 框架仍然存在,这会阻止我的页面加载全屏。我尝试以各种方式使用 closeFlow(),例如:
$(document).ready(function () {
dgFlow = top.dgFlow || top.opener.top.dgFlow;
dgFlow.closeFlow();
if (window != top) {
top.location.replace(document.location);
}
})
但是,我似乎无法让它在 IE 或 Edge 中正常工作。
这是我用来调用嵌入式流程的代码:
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame" class="standard">
<input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
<input id="type" type="hidden" name="expType" value="light">
<input id="paykey" type="hidden" name="paykey" value=@ViewData["paykey"]></form>
<script src="https://www.paypalobjects.com/js/external/dg.js"></script>
<script>var dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'submitBtn' });</script>
有没有人可以帮助我在 IE 和 Edge 中完成这项工作?
最佳答案
好的,我使用 window.opener 解决了这个问题。因此,对于 Edge、IE 11、Chrome、FF 和 Opera,我的工作代码似乎是:
$(document).ready(function () {
if (window.opener) { // check if opened in popup
window.close();
}
if (window != top) {
top.location.replace(document.location);
}
})
到目前为止一切顺利......
关于javascript - 通过在 IE 11 中删除框架关闭 PayPal 灯箱并重新加载父页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41388380/