转。webapp开发小tips
备忘 -
Q: webapp点击一个按钮调用系统拨号:
- <a href="tel:12345654321">打电话给我a>
- <a href="sms:12345654321">发短信a>
- 或用于单元格:
- <td οnclick="location.href='tel:122'">
Q:如何用手机在上网的网页中链接访问跳转到手机本地qq上直接聊天?
mqqwpa://im/chat?chat_type=wpa&uin=XXXXXXXX&version=1(XXXXXXXX需要聊天的QQ号码)
栗子:
<nav class="nav_bottom"> <a href="tel:12345678911"><i>i>电话咨询a> <a href="#"><i> i>在线咨询a> <a href="mqqwpa://im/chat?chat_type=wpa&uin=1012944410&version=1"><i> i>QQ咨询a> <a href="#"><i> i>地图导航a> nav>
提交查询. 调用iphone 手机地图APP的简单实例:提交查询
参数q:可以是一个某地的地址也可以是一个经纬度坐标,也可以是一个查询语句
如:查询上海市普陀区地图:提交查询
如:输入经纬坐标查询地图,注意:纬度在前,经度在后,中间用逗号隔开,纬度在-90到+90间,北纬为正,经度在-180到+180之间,
东经为正。
提交查询
如果要进行更复杂的条件查询,请参考最下面的源链接,有多个参数时每个参数名间用&号连接.
提交查询.调用iphone 手机打电话功能实例:当点击下面的链接时会调用我们平时输入号码打电话时的界面
测试拨打电话功能
提交查询.调用iphone手机发邮件实例:当点击下面的链接的时候会自动调用手机的Email功能
测试发邮件功能
测试拨打电话功能.调用iphone手机发短信的功能:
测试发短信的功能
如果你是一名前端er,又想在移动设备上开发出自己的应用,那怎么实现呢?幸好,webkit内核的浏览器能帮助我们完成这一切。接触 webkit webApp的开发已经有一段时间了,现把一些技巧分享给大家 :
// 肖像模式样式 #landscape { display: none; } //横屏时使用的样式
3. 事件 : (请参考:指尖的下JS 系列文章)
| // 手势事件 touchstart //当手指接触屏幕时触发 touchmove //当已经接触屏幕的手指开始移动后触发 touchend //当手指离开屏幕时触发 touchcancel // 触摸事件 gesturestart //当两个手指接触屏幕时触发 gesturechange //当两个手指接触屏幕后开始移动时触发 gestureend // 屏幕旋转事件 onorientationchange // 检测触摸屏幕的手指何时改变方向 orientationchange // touch事件支持的相关属性 touches targetTouches changedTouches clientX // X coordinate of touch relative to the viewport (excludes scroll offset) clientY // Y coordinate of touch relative to the viewport (excludes scroll offset) screenX // Relative to the screen screenY // Relative to the screen pageX // Relative to the full page (includes scrolling) pageY // Relative to the full page (includes scrolling) target // Node the touch event originated from identifier // An identifying number, unique to each touch event |
4. 屏幕旋转事件:onorientationchange
添加屏幕旋转事件侦听,可随时发现屏幕旋转状态(左旋、右旋还是没旋)。例子:
| // 判断屏幕是否旋转 function orientationChange() { switch(window.orientation) { case 0: alert("肖像模式 0,screen-width: " + screen.width + "; screen-height:" + screen.height); break; case -90: alert("左旋 -90,screen-width: " + screen.width + "; screen-height:" + screen.height); break; case 90: alert("右旋 90,screen-width: " + screen.width + "; screen-height:" + screen.height); break; case 180: alert("风景模式 180,screen-width: " + screen.width + "; screen-height:" + screen.height); break; }; }; // 添加事件监听 addEventListener('load',function(){ orientationChange(); window.onorientationchange = orientationChange; }); |
> span>span>
10. 自动大写与自动修正
要关闭这两项功能,可以通过autocapitalize 与autocorrect 这两个选项:
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px"><input type="text" autocapitalize="off" autocorrect="off" />
- span>span>
11. WebKit CSS:
①“盒模型”的具体描述性质的包围盒块内容,包括边界,填充等等。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">-webkit-border-bottom-left-radius: radius;
- -webkit-border-top-left-radius: horizontal_radius vertical_radius;
- -webkit-border-radius: radius; //容器圆角
- -webkit-box-sizing: sizing_model; 边框常量值:border-box/content-box
- -webkit-box-shadow: hoff voff blur color; //容器阴影(参数分别为:水平X 方向偏移量;垂直Y 方向偏移量;高斯模糊半径值;阴影颜色值)
- -webkit-margin-bottom-collapse: collapse_behavior; 常量值:collapse/discard/separate
- -webkit-margin-start: width;
- -webkit-padding-start: width;
- -webkit-border-image: url(borderimg.gif) 25 25 25 25 round/stretch round/stretch;
- -webkit-appearance: push-button; //内置的CSS 表现,暂时只支持push-button
- span>span>
②“视觉格式化模型”描述性质,确定了位置和大小的块元素。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">direction: rtl
- unicode-bidi: bidi-override; 常量:bidi-override/embed/normal
- span>span>
③“视觉效果”描述属性,调整的视觉效果块内容,包括溢出行为,调整行为,能见度,动画,变换,和过渡。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">clip: rect(10px, 5px, 10px, 5px)
- resize: auto; 常量:auto/both/horizontal/none/vertical
- visibility: visible; 常量: collapse/hidden/visible
- -webkit-transition: opacity 1s linear; 动画效果 ease/linear/ease-in/ease-out/ease-in-out
- -webkit-backface-visibility: visibler; 常量:visible(默认值)/hidden
- -webkit-box-reflect: right 1px; 镜向反转
- -webkit-box-reflect: below 4px -webkit-gradient(linear, left top, left bottom,
- from(transparent), color-stop(0.5, transparent), to(white));
- -webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)));; //CSS 遮罩/蒙板效果
- -webkit-mask-attachment: fixed; 常量:fixed/scroll
- -webkit-perspective: value; 常量:none(默认)
- -webkit-perspective-origin: left top;
- -webkit-transform: rotate(5deg);
- -webkit-transform-style: preserve-3d; 常量:flat/preserve-3d; (2D 与3D)
- span>span>
④“生成的内容,自动编号,并列出”描述属性,允许您更改内容的一个组成部分,创建自动编号的章节和标题,和操纵的风格清单的内容。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">content: “Item” counter(section) ” “;
- This resets the counter.
- First section
- >two section
- three section
- counter-increment: section 1;
- counter-reset: section;
- span>span>
⑤“分页媒体”描述性能与外观的属性,控制印刷版本的网页,如分页符的行为。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">page-break-after: auto; 常量:always/auto/avoid/left/right
- page-break-before: auto; 常量:always/auto/avoid/left/right
- page-break-inside: auto; 常量:auto/avoid
- span>span>
⑥“颜色和背景”描述属性控制背景下的块级元素和颜色的文本内容的组成部分。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">-webkit-background-clip: content; 常量:border/content/padding/text
- -webkit-background-origin: padding; 常量:border/content/padding/text
- -webkit-background-size: 55px; 常量:length/length_x/length_y
- span>span>
⑦ “字型”的具体描述性质的文字字体的选择范围内的一个因素。报告还描述属性用于下载字体定义。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">unicode-range: U+00-FF, U+980-9FF;
- span>span>
⑧“文本”描述属性的特定文字样式,间距和自动滚屏。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">text-shadow: #00FFFC 10px 10px 5px;
- text-transform: capitalize; 常量:capitalize/lowercase/none/uppercase
- word-wrap: break-word; 常量:break-word/normal
- -webkit-marquee: right large infinite normal 10s; 常量:direction(方向) increment(迭代次数) repetition(重复) style(样式) speed(速度);
- -webkit-marquee-direction: ahead/auto/backwards/down/forwards/left/reverse/right/up
- -webkit-marquee-incrementt: 1-n/infinite(无穷次)
- -webkit-marquee-speed: fast/normal/slow
- -webkit-marquee-style: alternate/none/scroll/slide
- -webkit-text-fill-color: #ff6600; 常量:capitalize, lowercase, none, uppercase
- -webkit-text-security: circle; 常量:circle/disc/none/square
- -webkit-text-size-adjust: none; 常量:auto/none;
- -webkit-text-stroke: 15px #fff;
- -webkit-line-break: after-white-space; 常量:normal/after-white-space
- -webkit-appearance: caps-lock-indicator;
- -webkit-nbsp-mode: space; 常量: normal/space
- -webkit-rtl-ordering: logical; 常量:visual/logical
- -webkit-user-drag: element; 常量:element/auto/none
- -webkit-user-modify: read- only; 常量:read-write-plaintext-only/read-write/read-only
- -webkit-user-select: text; 常量:text/auto/none
- span>span>
⑨“表格”描述的布局和设计性能表的具体内容。
[html] view plain copy - <span style="background-color:rgb(255,255,255)"><span style="font-family:Microsoft YaHei; font-size:12px">-webkit-border-horizontal-spacing: 2px;
- -webkit-border-vertical-spacing: 2px;
- -webkit-column-break-after: right; 常量:always/auto/avoid/left/right
- -webkit-column-break-before: right; 常量:always/auto/avoid/left/right
- –webkit-column-break-inside: logical; 常量:avoid/auto
- -webkit-column-count: 3; //分栏
- -webkit-column-rule: 1px solid #fff;
- style:dashed,dotted,double,groove,hidden,inset,none,outset,ridge,solid
- span>span>
⑩“用户界面”描述属性,涉及到用户界面元素在浏览器中,如滚动文字区,滚动条,等等。报告还描述属性,范围以外的网页内容,如光标的标注样式和显示当您按住触摸触摸目标,如在iPhone上的链接。
[css] view plain copy - "background-color:rgb(255,255,255)">"font-family:Microsoft YaHei; font-size:12px">-webkit-box-align: baseline,center,end,start,stretch 常量:baseline/center/end/start/stretch
- -webkit-box-direction: normal;常量:normal/reverse
- -webkit-box-flex: flex_valuet
- -webkit-box-flex-group: group_number
- -webkit-box-lines: multiple; 常量:multiple/single
- -webkit-box-ordinal-group: group_number
- -webkit-box-orient: block-axis; 常量:block-axis/horizontal/inline-axis/vertical/orientation
- –webkit-box-pack: alignment; 常量:center/end/justify/start
-
12. 动画过渡
这是 Webkit 中最具创新力的特性:使用过渡函数定义动画。
[css] view plain copy - "background-color:rgb(255,255,255)">"font-family:Microsoft YaHei; font-size:12px">-webkit-animation: title infinite ease-in-out 3s;
- animation 有这几个属性:
- -webkit-animation-name: //属性名,就是我们定义的keyframes
- -webkit-animation-duration:3s //持续时间
- -webkit-animation-timing-function: //过渡类型:ease/ linear(线性) /ease-in(慢到快)/ease-out(快到慢) /ease-in-out(慢到快再到慢) /cubic-bezier
- -webkit-animation-delay:10ms //动画延迟(默认0)
- -webkit-animation-iteration-count: //循环次数(默认1),infinite 为无限
- -webkit-animation-direction: //动画方式:normal(默认 正向播放); alternate(交替方向,第偶数次正向播放,第奇数次反向播放)
-
这些同样是可以简写的。但真正让我觉的很爽的是keyframes,它能定义一个动画的转变过程供调用,过程为0%到100%或from(0%)到to(100%)。简单点说,只要你有想法,你想让元素在这个过程中以什么样的方式改变都是很简单的。
[css] view plain copy - "background-color:rgb(255,255,255)">"font-family:Microsoft YaHei; font-size:12px">-webkit-transform: 类型(缩放scale/旋转rotate/倾斜skew/位移translate)
- scale(num,num) 放大倍率。scaleX 和 scaleY(3),可以简写为:scale(* , *)
- rotate(*deg) 转动角度。rotateX 和 rotateY,可以简写为:rotate(* , *)
- Skew(*deg) 倾斜角度。skewX 和skewY,可简写为:skew(* , *)
- translate(*,*) 坐标移动。translateX 和translateY,可简写为:translate(* , *)。
-
实现模拟弹出消息框(Alert)的例子:
①定义过渡(在
①定义过渡(在