[英]Close PayPal lightbox and Reload Parent Page by Removing Frames in IE 11
我正在將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);
}
})
到現在為止還挺好.......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.