• HTML5 隐藏地址栏 兼容IOS 与安卓


     现在有一个问题: 如果手机是 一屏一屏的滑动的,就不能 隐藏了。

    来源:https://github.com/scottjehl/Hide-Address-Bar

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>Test page</title><title>Cross-device Address Bar Hide - Example 1</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="hide-address-bar.js"></script>
        <style>
            /* DEMO ONLY for this short page - remove in live code */
            body { min-height: 480px; }
        </style>
    </head>
    <body>
    <p>The script on this page should hide the address bar on iOS and Android.</p>
    </body>
    </html>
    
        <script type="text/javascript">
            (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 );
        </script>
    View Code

    这两个 标签 也是隐藏 地址栏的,但是IOS 上苹果浏览器不起作用。

    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

     还有一个问题关于微信的

    用微信打开网页时, 用把 数字 变色 ,还可以拨号。 禁止这样情况 在网页头部加上:

    <meta content="telephone=no" name="format-detection" /> 

  • 相关阅读:
    网络模块axios的简单应用
    UWP App国际化的两种实现
    C# 显示函数调用方的详细信息
    UWP SVG 转 Glyph
    UWP 区分设备类型
    Flutter 星标已正式超过React Native
    查看Github星标排行榜
    博客园部分非公开api
    模块化(零):综述
    模块化一:提取模块
  • 原文地址:https://www.cnblogs.com/yjhua/p/4636363.html
Copyright © 2020-2023  润新知