Hiding the Address on Mobile Browsers

1

Stats

2,996 visits, 4,408 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 25 Feb, 2014. Last updated 19 Feb, 2019

I thought I post up these examples on hiding the address bar since there is NOT a lot on the forum or tutorials to help cover this. I tested these and they work well with Android (except Chrome browser).

Place the following JavaScript in your index.html,

inside the <body> tag.

I use the first 2 together

--------------------------------------------------------------------------------

This one works when device rotates

--------------------------------------------------------------------------------

    	<script>

function hideAddressBar(){

if(document.documentElement.scrollHeight<window.outerHeight/window.devicePixelRatio)

    document.documentElement.style.height=(window.outerHeight/window.devicePixelRatio)+'px';

setTimeout(window.scrollTo(1,1),0);

}

window.addEventListener("load",function(){hideAddressBar();});

window.addEventListener("orientationchange",function(){hideAddressBar();});

</script>

--------------------------------------------------------------------------------------------------

        <script>
		

if(navigator.userAgent.match(/Android/i)){

    window.scrollTo(0,1);

}

</script>

--------------------------------------------------------------------------------------------------

<script>

function hideAddressBar()

{

if(!window.location.hash)

{

      if(document.height < window.outerHeight)
      {
          document.body.style.height = (window.outerHeight + 50) + 'px';
      }

      setTimeout( function(){ window.scrollTo(0, 1); }, 50 );

}

}

window.addEventListener("load", function(){ if(!window.pageYOffset){ hideAddressBar(); } } );

window.addEventListener("orientationchange", hideAddressBar );

</script>

-----------------------------------------------------------------------------------------------------

This one triggers with a timeout function.

<Script>

// When ready...

window.addEventListener("load",function() {

// Set a timeout...

setTimeout(function(){

    // Hide the address bar!
     window.scrollTo(0, 1);

}, 0);

});

<Script>

-------------------------------------------------------------------------------------------------------

Good Luck with it and give me a thumbs up :)

  • 0 Comments

Want to leave a comment? Login or Register an account!