Move End WebApp Hide Address bar method _android

Source: Internet
Author: User

1, a lot of information said, add the following code, you can hide the address bar, but I tried many times, seemingly unsuccessful AH.

Copy Code code as follows:

<meta name= "apple-mobile-web-app-capable" content= "yes"/>

2, we can use another way to hide the address bar. Scrolling through the window after the page is loaded, this really works, the only thing to note is that the page height must be high enough, the core code is as follows:
Copy Code code as follows:

<script type= "Text/javascript" >
AddEventListener ("Load", function () {settimeout (Hideurlbar, 0);}, False);
function Hideurlbar () {
Window.scrollto (0,1);
}
</script>

3, but when the page Height Adaptive window (height:100%), the above method does not apply, we need to adopt a special method:
Copy Code code as follows:

$ (' div '). css ("height", window.innerheight+100); Force content to exceed

Window.scrollto (0, 1);

$ ("div"). CSS ("height", window.innerheight); Reset to new height

Document.addeventlistener (' Touchmove ', function (e) {E.preventdefault ();}, False); If you don't want the page to slide, you can add this piece of code

4, share the Open source project

Moving the front interface in, we'll see the address bar, which doesn't look like an app, so how to hide the Address bar, which provides a more appropriate code to support iOS and Android.

Copy Code code as follows:

/*! Normalized address bar hiding for IOS & Android (c) @scottjehl MIT License * *
(function (Win) {
var doc = win.document;

If there ' s a hash, or addeventlistener is undefined, stop here
if (!win.navigator.standalone &&!location.hash && win.addeventlistener) {

Scroll to 1
Win.scrollto (0, 1);
var scrolltop = 1,
Getscrolltop = function () {
return Win.pageyoffset | | Doc.compatmode = = "Css1compat" && Doc.documentElement.scrollTop | | Doc.body.scrollTop | | 0;
},

Reset to 0 on Bodyready, if needed
Bodycheck = setinterval (function () {
if (doc.body) {
Clearinterval (Bodycheck);
ScrollTop = Getscrolltop ();
Win.scrollto (0, scrolltop = 1 = 0:1);
}
}, 15);

Win.addeventlistener ("Load", function () {
settimeout (function () {
At load, if user hasn ' t scrolled than ...
if (Getscrolltop () < 20) {
Reset to hide addr bar at onload
Win.scrollto (0, scrolltop = 1 = 0:1);
}
}, 0);
}, False);
}
}) (this);


Please visit the details: Https://github.com/scottjehl/Hide-Address-Bar

If your browser supports tag concealment:

Copy Code code as follows:

<meta name= "apple-mobile-web-app-capable" content= "yes"/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.