19

Possible Duplicate:
Removing address bar from browser (to view on Android)

I'm trying to run a web-based application in Android, and I want to hide the webpage address bar while running the application. Is that possible? How do I do it?

Community
  • 1
  • 1
  • 1
    A better more detailed answer/explanation can be found here. http://stackoverflow.com/questions/4068559/removing-address-bar-from-browser-to-view-on-android – worked Feb 26 '11 at 23:09

3 Answers3

16

Executing this JavaScript on document load will scroll the browser down so that the address bar is off screen:

window.scrollTo(0, 1);

That's probably as good as you're going to get without writing a native Android app with a WebView to display your webapp in.

Edit: Note that this only works for the old default Android browser. It does not work with Chrome.

Mark B
  • 183,023
  • 24
  • 297
  • 295
13

You don't need to use Javascript at all, the Android browser is WebKit based. Adding the following lines

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

in the <head> portion of your page will give the desired result.

Phil
  • 1,288
  • 1
  • 10
  • 19
Fuzzy
  • 847
  • 9
  • 23
  • 4
    Just wanted to add here the comment Stated by Ryan Wheale below: "you cannot rely on the "apple" tags suggested by @Fuzzy. While it may have worked at one time for some Android devices - it is not officially supported by Android OS." – Antti Rytsölä Sep 01 '11 at 06:40
  • I have yet to get any of Apple's tags to work correctly in a sane manner with Android.. Honestly, its a guessing game it seems. Please refrain from stating the obvious things we have already tried, and find ourselves here looking because they never worked in the first place. – John Drefahl Jan 20 '12 at 22:33
  • @Fuzzy - The apple meta tags you suggested actually prevent the window-scroll from occurring. – AVProgrammer Jan 21 '12 at 20:46
  • @Fuzzy Hi. I have used this code in my website. I opened my website from Safari app in iPhone/iPad but the Safari's url and status bar remained visible. :(. All i want is to hide status and url bar when my website is opened in Safari browser app. – Kartik Domadiya Sep 12 '12 at 08:14
  • 3
    This only applies to web apps installed to home screen (in Safari, tap the middle action button at the bottom and choose "Add to Home Screen"). – vit Nov 02 '12 at 01:12
1

You'll need to add your own WebView. Basic help here : http://developer.android.com/guide/tutorials/views/hello-webview.html

Really, don't forget shouldOverrideUrlLoading() which will redirect all your click in your webview instead of the default browser.

Shikiryu
  • 10,180
  • 8
  • 49
  • 75