Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Location toolbar from IONIC Native InAppBrowser

Reading the cordova documentation inappbrowser I can not find a way to hide the Location Toolbar (ALWAYS AND WHEN it has "location = yes") and just for Android, becouse we can use "toolbar=no" on IOs.

Why the need to have active "location = yes"? You can put "no" and it does not appear anymore.

As I comment in this thread, I need the activated option to be able to make use of the functions of ionic native IAB

Options i use:

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

enter image description here

As we can see in the image, the toolbar still appears at the top.

Any option that has been overlooked? Is it possible to remove it with CSS, if so, does it have any Class or ID to call, or should I touch it with pure code?

like image 412
acruma Avatar asked Jul 17 '19 06:07

acruma


People also ask

How do I hide my URL in the app browser?

Is it possible to hide the website URL at top of the in-app browser? No this is not possible. It is controlled by the browser itself.

What is InAppBrowser?

Introducing InAppBrowser.com, a simple tool to list the JavaScript commands executed by the iOS app rendering the page.


1 Answers

for ios to implement use this code if you are viewing the .html or .pdf file it hide the address bar call this function getFileExtension from your code.

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');
       }

similar like for android but very minor changes are there

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
        });
    }

i place both the code here might be its repeated catch it which you want. I hope this will help you.

like image 139
Pritish Avatar answered Oct 16 '22 08:10

Pritish