您的位置:首页 > 移动开发

app wap开发mobile隐藏地址栏的js

2013-07-13 20:14 253 查看
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屏幕可以支持双倍,但是不支持,图片显示不出来。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: