【问题标题】:Hide Location toolbar from IONIC Native InAppBrowser从 IONIC Native InAppBrowser 隐藏位置工具栏
【发布时间】:2019-11-25 22:19:17
【问题描述】:

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

为什么需要激活“location = yes”?你可以输入“否”,它就不再出现了。

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

我使用的选项:

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

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

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

【问题讨论】:

  • location=no 在您的选项中
  • 这是在安卓还是在哪里?
  • 是的,是IONIC和平台android

标签: cordova ionic-framework webview inappbrowser


【解决方案1】:

ios 如果您正在查看 .html 或 .pdf 文件,请使用此代码来实现,它会隐藏地址栏,请从您的代码中调用此函数 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
        });
    }

我把这两个代码都放在这里可能是你想要的重复捕获它。我希望这会对你有所帮助。

【讨论】:

    【解决方案2】:

    根据

    https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/

    设置toolbar=no

    var dataref = cordova.InAppBrowser.open(url, target, options)<--------pass to this place
    

    工具栏:设置为是或否以打开或关闭工具栏 InAppBrowser(默认为是)

    【讨论】:

    • 这只是 IOs
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-22
    • 2023-03-26
    • 1970-01-01
    相关资源
    最近更新 更多