$ cordovaInAppBrowser打开网址显示地址栏很奇怪

时间:2017-12-07 12:57:28

标签: cordova ionic-framework cordova-plugins inappbrowser

当我点击网址使用$cordovaInAppBrowser.open(url, '_blank', options)打开网址时,它会在打开InAppBrowser时将其退回到网址,它会显示奇怪的行为。

这是我的代码

    var options = {
        location: 'yes',
        clearcache: 'yes',
        toolbar: 'no'
    };
    $cordovaInAppBrowser.open(url, '_blank', options)
    .then(function (event) {
        // success
    })
    .catch(function (event) {
        // error
    });

enter image description here

2 个答案:

答案 0 :(得分:1)

您可以尝试以下选项。

iOS:

cordova.InAppBrowser.open(yourURL, '_blank', 'toolbar=no');

Android:

cordova.InAppBrowser.open(yourURL, '_blank', 'location=no');

在您的情况下, cordova.InAppBrowser $cordovaInAppBrowser

答案 1 :(得分:0)

我可以使用Android和ios的代码来解决它

  self.viewLink = function (viewUrl) {

        var url = (viewUrl.match('http')) ? viewUrl : 'http://' + viewUrl;
        var options = {
            location: 'no',
            clearcache: 'yes',
            toolbar: 'yes',
            closebuttoncaption: 'Done'
        };
        $cordovaInAppBrowser.open(url, '_blank', options)
        .then(function (event) {
            // success
        })
        .catch(function (event) {
            // error
        });
        return false;
    }

对我来说它完美无缺。希望对某些人有所帮助。