zoukankan      html  css  js  c++  java
  • app wap开发mobile隐藏地址栏的js

    function scrolltol (){
    setTimeout ( function () {
    window . scrollTo ( 0 , 1 )
    },
    0 );
    }
    window . onload = function () {
    if ( document . documentElement . scrollHeight <= document . documentElement . clientHeight ) {
    bodyTag = document . getElementsByTagName ( 'body' )[ 0 ];
    bodyTag . style . height = document . documentElement . clientWidth / screen . width * screen . height + 'px' ;
    }
    setTimeout ( function () {
    window . scrollTo ( 0 , 1 )
    },
    0 );
    };

    只要上面几行JS代码就可以搞定。

    之外再给大家推荐另一种方法:

    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" >

    设置viewport

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

    禁用电话

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

    启用web app。添加至主屏后,从主屏进入会隐藏地址栏和状态栏

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

    设置顶部电话信号那一栏的样式,可用值有default 、black、black-translucent三种,其中第三种为半透明,不占高度。

    <link rel="apple-touch-icon-precomposed" href="iphone_milanoo.png" />

    设置主屏的图标。该路径需要注意的就是放到将网站的文档根目录下但不是服务器的文档的根目录。图片尺寸可以设定为57*57(px)或者Retina可以定为114*114(px),ipad尺寸为72*72(px)

    <link rel="apple-touch-startup-image" href="milanoo_startup.png" />

    启动界面的图片。该路径需要注意的就是放到将网站的文档根目录下但不是服务器的文档的根目录。官方规定启动界面的尺寸必须为 320*640(px),原本以为Retina屏幕可以支持双倍,但是不支持,图片显示不出来。


  • 相关阅读:
    Vue3.0
    Vue
    Vue
    Vue3.0
    Vue
    Vue
    Vue
    Vue
    Vue3.0
    万字长文|十大基本排序,一次搞定!
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3188494.html
Copyright © 2011-2022 走看看