phonegap一些事件
/ 判断屏幕是否旋转
屏幕旋转事件: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;     };<br>};// 添加事件监听 addEventListener('load', function(){     orientationChange();     window.onorientationchange = orientationChange; });隐藏地址栏 & 处理事件的时候,防止滚动条出现:
/ 隐藏地址栏  & 处理事件的时候 ,防止滚动条出现
addEventListener('load', function(){         setTimeout(function(){ window.scrollTo(0, 1); }, 100); });双手指滑动事件:
// 双手指滑动事件addEventListener('load',  function(){ window.onmousewheel = twoFingerScroll;},      false              // 兼容各浏览器,表示在冒泡阶段调用事件处理程序 (true 捕获阶段)); function twoFingerScroll(ev) {     var delta =ev.wheelDelta/120;              //对 delta 值进行判断(比如正负) ,而后执行相应操作     return true; }; 判断是否为iPhone:
function isAppleMobile() {     return (navigator.platform.indexOf('iPad') != -1); }; localStorage:
var v = localStorage.getItem('n') ? localStorage.getItem('n') : "";   // 如果名称是  n 的数据存在 ,则将其读出 ,赋予变量  v  。 localStorage.setItem('n', v);                                           // 写入名称为 n、值为  v  的数据 localStorage.removeItem('n');         使用特殊链接:
 如果你关闭自动识别后 ,又希望某些电话号码能够链接到 iPhone 的拨号功能 ,那么可以通过这样来声明电话链接 ,
<a href="tel:12345654321">打电话给我</a><a href="sms:12345654321">发短信</a>或用于单元格:<td onclick="location.href='tel:122'">自动大写与自动修正
要关闭这两项功能,可以通过autocapitalize 与autocorrect 这两个选项:
要关闭这两项功能,可以通过autocapitalize 与autocorrect 这两个选项:
<input type="text" autocapitalize="off" autocorrect="off" /> 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号