zoukankan      html  css  js  c++  java
  • 移动前端:在手机上隐藏地址工具栏

    移动前端界面进去的时候,我们会看到地址工具条,这看起来不怎么像一个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 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 more than 20 or so...
    if( getScrollTop() < 20 ){
    //reset to hide addr bar at onload
    win.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" />
  • 相关阅读:
    2017年寒假作业(二)
    2017年寒假作业(一)
    JAVA类型转换
    两数之和(LeetCode)
    编程汇总
    赌神(赛码网基础算法题)
    个人作业——软件工程实践总结
    个人作业——软件产品案例分析
    交换队伍交接过程及个人心得
    软件工程结对作业第二次
  • 原文地址:https://www.cnblogs.com/cyweb/p/4120838.html
Copyright © 2011-2022 走看看