移動前端:在手機上隱藏地址工具列

來源:互聯網
上載者:User

標籤:android   http   io   ar   os   sp   for   on   cti   

移動前端介面進去的時候,我們會看到地址工具條,這看起來不怎麼像一個APP,那麼怎麼隱藏掉這個地址條,下面提供了一個比較合適的代碼,支援IOS和Android.

/*! 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 hereif(!win.navigator.standalone && !location.hash && win.addEventListener ){//scroll to 1win.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 neededbodycheck = 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 more than 20 or so...if( getScrollTop() < 20 ){//reset to hide addr bar at onloadwin.scrollTo( 0, scrollTop === 1 ? 0 : 1 );}}, 0);}, false );}})( this );

詳細請訪問:https://github.com/scottjehl/Hide-Address-Bar

如果你的瀏覽器支援標籤隱藏的話:

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

移動前端:在手機上隱藏地址工具列

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.