PayPal灯箱无法在iPhone Safari/网络应用中打开; 'win.location'未定义 [英] PayPal lightbox won't open in iPhone safari/web app; 'win.location' undefined
问题描述
(在iPhone
的Chrome
中可以正常工作)
(works fine in Chrome
on the iPhone
)
我收到此错误:
TypeError: 'undefined' is not an object (evaluating 'win.location') in dg.js line 3
灯箱无法打开.
贝宝(PayPal)的 dg.js 内的相关代码为:
The code in question inside PayPal's dg.js is:
startFlow: function (url) {
var win = that._render();
if (win.location) {
win.location = url;
} else {
win.src = url;
}
}
那么手机Safari
不理解that._render()
吗?我该如何解决?
So does mobile Safari
not understand that._render()
? How do I get around this?
如果有关系,我正在使用Adaptive Payments
,这样称呼它:
If it matters, I'm using Adaptive Payments
, calling it like so:
var dg = new PAYPAL.apps.DGFlow({
trigger: null,
expType: 'light'
});
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
在获取payKey
& ;;时,我没有任何问题.整个payflow
都可以在桌面和Safari
以外的移动浏览器中使用(它可以在桌面Safari
上使用).当我们的网站作为iOS
网络应用程序运行时,它也无法正常工作,我认为这只是Safari
的外壳.
I don't have any problems getting the payKey
& the entire payflow
works on desktops and in mobile browsers other than Safari
(it works on desktop Safari
). It also does not work when our site is run as an iOS
web app, which I assume is just a shell for Safari
anyway.
推荐答案
找到了几种通过PayPal URL或使用自己的灯箱解决此问题的方法.location.replace
我使用了 easybox .
Found a couple of ways to get around this...location.replace
with the PayPal URL or using your own lightbox. I used easybox.
// Replace
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
// with
var RUNNING_AS_WEB_APP = (window.navigator.standalone == true ? true : false);
if (RUNNING_AS_WEB_APP === false) {
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
} else {
location.replace('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
// Or, lightbox option:
// $.easybox([{url: 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey, width: 320, height: 480}]);
}
这篇关于PayPal灯箱无法在iPhone Safari/网络应用中打开; 'win.location'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!