简体   繁体   English

Ionic 2-inAppBrowser问题

[英]Ionic 2 - inAppBrowser issue

I am very new to this Ionic 2 Framework and have never worked with Cordova. 我对Ionic 2框架非常陌生,从未与Cordova合作。

I am sending users to the payment gateway page to complete the transaction and once completed I am not able to close the window using JavaScript, due to this error: 我将用户发送到支付网关页面以完成交易,一旦完成,由于以下错误,我将无法使用JavaScript关闭窗口:

Scripts may close only the windows that were opened by it 脚本可能只关闭由它打开的窗口

Have tried all possible way but none of them can be put in use. 尝试了所有可能的方法,但没有一个可以使用。

Even closing the inAppBrowser once the user is navigated to a specific URL will work, but I am unable to find any supporting document to this and I do feel this is possible. 即使在用户导航到特定URL后关闭inAppBrowser也可以,但是我找不到与此相关的任何支持文档,并且我确实认为这是可能的。

If you are using inAppBrowser plugin ( https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/ ) you can add event listener and check if specific url was opened. 如果您使用的是inAppBrowser插件( https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/ ),则可以添加事件侦听器并检查是否打开了特定的URL。

Example: 例:

inAppBrowser.addEventListener("loadstop", function (event) {
    if (event.url.indexOf('UrlIAmChecking') != -1) { 
            inAppBrowser.close();
    }
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM