阅读cordova documentation inappbrowser时,我找不到隐藏“位置工具栏”的方法(总是并且当它具有“location = yes”时),并且仅对于Android,因为我们可以在IO上使用“toolbar = no”。

为什么需要事件的“位置=是”?您可以输入“no”,它不再出现。

当我在thread中评论时,我需要激活的选项才能使用 ionic native IAB的功能

我使用的选项:

location=yes,
EnableViewPortScale=yes,
hidenavigationbuttons=yes,
enableViewportScale=yes,
hideurlbar=yes,
zoom=no,
mediaPlaybackRequiresUserAction=yes,

cordova - 通过IONIC Native InAppBrowser隐藏位置工具栏-LMLPHP

正如我们在图像中看到的,工具栏仍显示在顶部。

有没有被忽视的选择?
是否可以使用CSS删除它,如果有,它是否可以调用任何Class或ID,还是应该用纯代码触摸它?

最佳答案

如果您正在查看.html或.pdf文件,则可以实现ios 来使用此代码,它会隐藏地址栏,从您的代码中调用此函数getFileExtension

function getFileExtension(filename) {
           var fileName = filename.split('.').pop();
           if (fileName == 'pdf')
           {
               viewLinkpdf(filename)
           }
           else
           {
               viewLink(filename)
           }
       }
       function viewLink(filepath) {
            var url = (filepath.match('http')) ? filepath : 'http://' + filepath;
            var win = window.open( url, "_blank", "location=no" );
       }

function viewLinkpdf(filepath) {
           var url = (filepath.match('http')) ? filepath : 'http://' + filepath;
            window.open(encodeURI('https://docs.google.com/gview?embedded=true&url='+url), '_blank', 'location=no,EnableViewPortScale=yes');
       }

类似,类似于android ,但其中存在非常小的更改
function viewLinkpdf(filepath) {
        var url = (filepath.match('http')) ? filepath : 'http://' + filepath;
        window.open(encodeURI('https://docs.google.com/gview?embedded=true&url='+url), '_blank', 'location=no,EnableViewPortScale=yes');
    }
    function getFileExtension(filename) {
        var fileName = filename.split('.').pop();
        if (fileName == 'pdf')
        {
            viewLinkpdf(filename)
        }
        else
        {
            viewLink(filename)
        }
    }
    function viewLink(filepath) {
        var url = (filepath.match('http')) ? filepath : 'http://' + filepath;
        var options = {
            location: 'no',
            clearcache: 'yes',
            toolbar: 'no'
        };
        $cordovaInAppBrowser.open(url, '_blank', options)
        .then(function (event) {
            // success
        })
        .catch(function (event) {
            // error
        });
    }

我将这两个代码都放在这里,可能是您想要重复捕获它。我希望这能帮到您。

10-04 22:43
查看更多