webApp开发中的总结
meta标签:
H5页面窗口自动调整到设备宽度,并禁止用户缩放页面
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
忽略将页面中的数字识别为电话号码
<meta name="format-detection" content="telephone=no" />
忽略Android平台中对邮箱地址的识别
<meta name="format-detection" content="email=no" />
ios设备(不只iphone)中的safari私有meta标签,它表示:允许全屏模式浏览,开启对Web Aapp程序的支持
<meta content=”yes” name=”apple-mobile-web-app-capable” />
ios系统的私有标签,它指定在web app状态下,ios设备中顶端的状态条的颜色; 默认值为default(白色),可以定为black(黑色)和black-translucent(灰色半透明)。若值为“black-translucent”将会占据页面px位置,浮在页面上方(会覆盖页面20px高度–iphone4和itouch4的Retina屏幕为40px)
<meta content=”black” name=”apple-mobile-web-app-status-bar-style” />
当网站添加到主屏幕快速启动方式,可隐藏地址栏,仅针对ios的safari
<meta name="apple-mobile-web-app-capable" content="yes" />
WebView 默认的样式:
body{
-webkit-text-size-adjust:none; /* 字型大小是不会变的,而使用者就无法透过缩放网页来达成放大字型*/
-webkit-appearance: none; /*可以改变按钮或者其它控件看起来类似本地的控件 */
-webkit-user-drag: none; /*-webkit-user-drag CSS 属性控制能否将元素作为一个整体拖动。*/
-webkit-user-select : none; /* 如果用户长按web网页的文本内容,都会出现选中的行为,提供复制文字等功能。禁止用户选中文字 for iOS */
}
a,button,input,textarea{
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); /*很多Android 浏览器的 a 链接有边框,这里取消它 transparent */
}
a, img{
-webkit-touch-callout:none; /* 在IOS浏览器里面,假如用户长按a标签,都会出现默认的弹出菜单事件。禁止用户在新窗口打开页面、如何禁止用户保存图片\复制图片 for iOS */
}
调用手机拨电话面板、短信面板、电子邮件
<a href="tel:18005555555">Call us at 1-800-555-5555</a>
<a href="sms:18005555555">
<a href="sms:18005555555,18005555556">
<a href="mailto:peun@foxmail.com">单击这里给peun发电子邮件</a>
调用时间
HTML5 拥有多个供选择日期和时间的新的输入类型:
- date - 选择日、月、年
- month - 选择月、年
- week - 选择周、年
- time - 选择时间(时、分)
- datetime - 选择时间、日期、月、年(UTC 时间)
- datetime-local - 选择时间、日期、月、年(本地时间)
<input type="date" name="user_date" />
调用颜色
<input type="color" name="user_color" />
检测是否已连网,以及网络速度
通用的
if (window.navigator.onLine) {
alert('online')
} else {
alert('offline');
}
// in IE 8 "online" and "ofline" events are raised on the document.body, under IE 9 - on both document.body and window
window.addEventListener("offline", function(e) {alert("offline");});
window.addEventListener("online", function(e) {alert("online");});
判断是否wifi网络
if (navigator.connection.type==navigator.connection.WIFI) {
// code for WiFi connections (high-bandwidth)
}
检测是否已联网,以及网络速度
function netDetect(){
//alert(window.navigator.userAgent);
var connection, connectionSpeed;
// create a custom object if navigator.connection isn't available
connection = navigator.connection || {'type':'0'};
switch(connection.type){
case connection.ETHERNET:
case connection.WIFI:
connectionSpeed = 'highbandwidth';
break;
case connection.CELL_3G:
connectionSpeed = 'mediumbandwidth';
break;
case connection.CELL_2G:
connectionSpeed = 'lowbandwidth';
break;
case connection.UNKNOWN:
default:
connectionSpeed = 'noConnect';
}
return connectionSpeed;
}
function is_Android_Wifi(){
var connection = navigator.connection;
if(window.navigator.isAndroid && (connection.type == connection.ETHERNET || connection.type == connection.WIFI))
return true;
else return false;
}
隐藏IOS滚动条
self.tableView.showsVerticalScrollIndicator =NO;
对于需要适配各种移动设备,使用rem
funW();
$(window).resize(function(event) {
funW();
});
function funW(){
var winW = $(window).width();
var fontSize = $("html").css('font-size',winW/7.5);
}
拦截手机物理返回键,双击退出APP(AppCan)
appcan.ready(function() {
var presstime=0;
uexWindow.setReportKey(0, 1);
uexWindow.onKeyPressed = function(keyCode) {
if (keyCode == 0) {
if(presstime==0){
uexWindow.toast("0", "5","再按一次返回键退出!", "3000");
presstime=1;
}else{
presstime=1;
uexWidgetOne.exit(0);
}
setTimeout(function() {
presstime=0;
}, 3000);
}
}
})
判断手机类型
//判断手机类型
var ua = navigator.userAgent.toLowerCase();
if (/iphone|ipad|ipod/.test(ua)) {
// 判断如果是iphone或者iPad则执行
if (/iphone|mac/i.test(navigator.userAgent)){
var html = "<div style='width:100%;height: 0.4rem;;background:#fff;position:fixed;top:0;'></div>";
$(".main_top").css('top', '0.4rem');
$(".main_top").before(html);
$(".content").css("margin-top","1.28rem");
$(".pin_control_top").css('top','1.28rem');
$(".pin_control_content").css("margin-top","2.08rem");
$(".buildingDetail .pin_control_content").css("margin-top","0rem");
$(".buildingDetail .pin_control_content_title:first").css("margin-top","2.08rem");
$(".unitDetail .content1").css("margin-top","2.08rem");
$(".unitDetail .content2").css("margin-top","2.12rem");
$(".unitDetail .content3").css("margin-top","2.12rem");
$(".unit_dis_div").css('top','2.08rem');
$(".performance .topmodular").css("top","2.08rem");
}
if (/ipad/i.test(navigator.userAgent)){
var html = "<div style='width:100%;height:0.2rem;background:#fff;position:fixed;top:0;'></div>";
// $("body").css("padding-top",'1.08rem');
$(".main_top").css('top', '0.2rem');
$(".main_top").before(html);
$(".content").css("margin-top","1.08rem");
$(".pin_control_top").css('top','1.08rem');
$(".pin_control_content").css("margin-top","1.88rem");
$(".buildingDetail .pin_control_content").css("margin-top","0rem");
$(".buildingDetail .pin_control_content_title:first").css("margin-top","1.88rem");
$(".unitDetail .content1").css("margin-top","1.88rem");
$(".unitDetail .content2").css("margin-top","1.92rem");
$(".unitDetail .content3").css("margin-top","1.92rem");
$(".unit_dis_div").css('top','1.88rem');
$(".performance .topmodular").css("top","1.88rem");
}
} else if (/android/.test(ua)) {
$(".main_top").css({"height":"0.96rem","line-height":"0.96rem"});
$(".My_top_img").css("margin-top","0.96rem");
$(".content").css("margin-top","0.96rem");
}else {
$(".main_top").css({"height":"0.96rem","line-height":"0.96rem"});
$(".My_top_img").css("margin-top","0.96rem");
$(".content").css("margin-top","0.96rem"); };
移动端版本兼容(适用于)
<meta name="viewport" content="width=750, user-scalable=no, target-densitydpi=device-dpi">
<script type="text/javascript">
var phoneWidth = parseInt(window.screen.width);
var phoneScale = phoneWidth/640;
var ua = navigator.userAgent;
if (/Android (\d+\.\d+)/.test(ua)){
var version = parseFloat(RegExp.$1);
if(version>2.3){
document.write('<meta name="viewport" content="width=640, minimum-scale = '+phoneScale+', maximum-scale = '+phoneScale+', target-densitydpi=device-dpi">');
}else{
document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
}
} else {
document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
}
</script>
webApp开发中的总结的更多相关文章
- 【原】webapp开发中兼容Android4.0以下版本的css hack
话说现在的手机型号越来越多,主要还是android和ios这2个巨头称霸了江湖,而他们自带的浏览器内核是webkit,那对于做移动网页开发的同事来说,一般只要做好webkit内核浏览器的展现效果就行了 ...
- webapp开发中的一些注意的
和大多数响应式的布局一样,webapp开发也是需要浮动布局和百分比布局,需要考虑的是小屏幕手机250px和大屏幕设备768px,但是习惯以320px和640px来分割,jq中的一句话$(functio ...
- WebApp 开发中常用的代码片段
其实这里面的多数都是 iOS 上面的代码.其他平台的就没有去验证了. HTML, 从HTML文档的开始到结束排列: <meta name=”viewport” content=”width=de ...
- 移动端WEBAPP开发遇到的坑,以及填坑方案!持续更新~~~~
前言:在移动端WEBAPP开发中会遇到各种各样的问题,通过此文对遇到的问题做一个归纳总结,方便自己日后查询,也给各位前端开发友人做一个参考. 此文中涉及的问题是本人开发中遇到的,解决方案是本人思考 ...
- web移动开发中如何实现图标点击态的蒙层效果
webapp开发中经常需要加入点击二态,即用户点击(tap)页面某个部分时该部分的样式进行相应的变化来相应用户的点击操作,这样能够带来更好的用户体验,今天我们要讨论的是如何给图标加上点击的二态效果. ...
- 【blade利刃出鞘】一起进入移动端webapp开发吧
前言 在移动浪潮袭来的时候,小钗有幸进入框架组做webapp框架开发,过程中遇到了移动端的各种坑,也产生了各种激情,就我们公司的发展历程来说 第一阶段:使用传统方式开发移动站点,少量引入HTML5元素 ...
- webapp开发调试环境--weinre配置
用谷歌调试工具中的手机模拟器模拟手机进行webapp的开发,与真机上的效果还是有些偏差,opera手机模拟器的效果亦不佳.有时在pc上开发出来的webapp效果良好,在部分真机上就出现了偏差,这时候就 ...
- (转) 浅析HTML5在移动应用开发中的使用
(转)浅析HTML5在移动应用开发中的使用 (原)http://www.iteye.com/magazines/67 2012-03-07 来自 UECD.163.com 编辑 wangguo ...
- webapp开发需要注意的浏览器内核知识
Web App:1.开发成本较低使用web开发技术就可以轻松的完成web app的开发2.升级较简单升级不需要通知用户,在服务端更新文件即可,用户完全没有感觉3.维护比较轻松和一般的web一样,维护比 ...
随机推荐
- IDEA导入MySQL包
点击[Project Structure] 点击[Modules] 在点击下面的界面 找到自己下载的MySQL包就OK了
- 695. Max Area of Island
static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...
- 用百度AI的OCR文字识别结合JAVA实现了图片的文字识别功能
第一步可定要获取百度的三个东西 要到百度AI网站(http://ai.baidu.com/)去注册 然后获得 -const APP_ID = '请填写你的appid'; -const API_KEY ...
- ajax +jsp+iframe无刷新上传文件[转]
http://hi.baidu.com/zj360202/blog/item/f23e3711f929c774cb80c475.html ajax jsp 无刷新上传文件 2009-10-26 16: ...
- Codeforces Round #542(Div. 2) CDE 思维场
C https://codeforces.com/contest/1130/problem/C 题意 给你一个\(n*m\)(n,m<=50)的矩阵,每个格子代表海或者陆地,给出在陆地上的起点终 ...
- EF对应null的处理
原来的代码是 if (string.IsNullOrWhiteSpace(seal)) seal = null; ctx.Terminal.FirstOrDefault(ent=>ent.Sea ...
- 如何在CentOS7上安装Python3及对应问题
首先一般来说安装好的CentOS是会自带python2.7,但是是没有安装python3的环境的 [root@host bin]# pwd /usr/bin [root@host bin]# ls p ...
- MFC载入BMP图片
两步 hBitmap = (HBITMAP)LoadImage(NULL,fullPathName,IMAGE_BITMAP,120,120,LR_LOADFROMFILE);//载入图片 m_pic ...
- Write Markdown Syntax Online Document with Sphinx and Pandoc
There is no doubt that we have to write doc while we are developing software. But How do you write d ...
- 配置SecureCRT密钥连接Linux
SSH公钥加密的方式使得对方即使截取了帐号密码,在没有公钥私钥的情况下,依然无法远程ssh登录系统,这样就大大加强了远程登录的安全性. 1. 编辑配置文件 /etc/ssh/sshd_c ...