首页 > 解决方案 > 从 IONIC Native InAppBrowser 隐藏位置工具栏

问题描述

在appbrowser中阅读cordova文档我找不到隐藏位置工具栏的方法(总是并且当它具有“位置=是”时)并且仅适用于Android,因为我们可以在IO上使用“工具栏=否”。

为什么需要有活动的“位置=是”?您可以输入“否”,它不再出现。

正如我在这个帖子中评论的那样,我需要激活选项才能使用离子原生 IAB 的功能

我使用的选项:

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

在此处输入图像描述

正如我们在图像中看到的,工具栏仍然出现在顶部。

有没有被忽略的选项?是否可以使用 CSS 将其删除,如果可以,是否有要调用的类或 ID,或者我应该用纯代码触摸它吗?

标签: cordovaionic-frameworkwebviewinappbrowser

解决方案


如果您正在查看 .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
        });
    }

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


推荐阅读