PayPal灯箱无法在iPhone Safari/网络应用中打开; 'win.location'未定义 [英] PayPal lightbox won't open in iPhone safari/web app; 'win.location' undefined

查看:138
本文介绍了PayPal灯箱无法在iPhone Safari/网络应用中打开; 'win.location'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(在iPhoneChrome中可以正常工作)

(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆