HTML5+學習筆記1-------邊看代碼邊研究中

document.addEventListener('touchstart',function(){
    return false;
},true);

touchstart當手指觸摸屏幕時候觸發,即便已經有一個手指放在屏幕上也會觸發。html

document.oncontextmenu=function(){
    return false;
};

oncontextmenu取消鼠標右鍵html5

var _domReady=false;
document.addEventListener('DOMContentLoaded',function(){
    _domReady=true;
    compatibleAdjust();
},false);

domready事件,相似jq的$(document).ready()web

var _adjust=false;
function compatibleAdjust(){
    if(_adjust||!window.plus||!_domReady){
        return;
    }
    _adjust=true;
    // iOS平臺使用div的滾動條
    if('iOS'==plus.os.name){
        document.getElementById('content').className='scontent';
    }
    // 預建立二級窗口
//    preateWebviews();
    // 關閉啓動界面
    setTimeout(function(){
        plus.navigator.closeSplashscreen();
    },500);
}

// 兼容性樣式調整瀏覽器

var _openw=null;
function clicked(id,a,s){
    if(_openw){return;}
    a||(a=as);
    _openw=preate[id];
    if(_openw){
        _openw.showded=true;
        _openw.show(a,null,function(){
            _openw=null;//避免快速點擊打開多個頁面
        });
    }else{
//        var wa=plus.nativeUI.showWaiting();
        _openw=plus.webview.create(id,id,{scrollIndicator:'none',scalable:false,popGesture:'hide'},{preate:true});
        preate[id]=_openw;
        _openw.addEventListener('loaded',function(){//葉面加載完成後才顯示
//        setTimeout(function(){//延後顯示可避免低端機上動畫時白屏
//            wa.close();
            _openw.showded=true;
            s||_openw.show(a,null,function(){
                _openw=null;//避免快速點擊打開多個頁面
            });
            s&&(_openw=null);//避免s模式下變量沒法重置
//        },10);
        },false);
        _openw.addEventListener('close',function(){//頁面關閉後可再次打開
            _openw=null;
            preate[id]&&(preate[id]=null);//兼容窗口的關閉
        },false);
    }
}

//處理點擊事件dom

var preate={};
function preateWebviews(){
    preateWebivew('plus/webview.html');
    var plist=document.getElementById('plist').children;
    // 因爲啓動是預建立過多Webview窗口會消耗較長的時間,因此這裏限制僅建立5個
    for( var i=0;i<plist.length&&i<2;i++){
        var id=plist[i].id;
        id&&(id.length>0)&&preateWebivew(id);
    }
}
function preateWebivew(id){
    if(!preate[id]){
        var w=plus.webview.create(id,id,{scrollIndicator:'none',scalable:false,popGesture:'hide'},{preate:true});
        preate[id]=w;
        w.addEventListener('close',function(){//頁面關閉後可再次打開
            _openw=null;
            preate[id]&&(preate[id]=null);//兼容窗口的關閉
        },false);
    }
}

 

 

// 清除預建立頁面(僅)
function preateClear(){
    for(var p in preate){
        var w=preate[p];
        if(w&&w.showded&&!w.isVisible()){
            w.close();
            preate[p]=null;
        }
    }
}

 

經過 HTML5 開發移動 App 時,會發現 HTML5 不少能力不具有。爲彌補 HTML5 能力 的不足,在 W3C 中國的指導下成立了 www.HTML5Plus.org組織,推出 HTML5+規範。ide

HTML5+擴展了 JavaScript 對象 plus,使得 js 能夠調用各類瀏覽器沒法實現或實現不佳的系統能力,設備能力如攝像頭、陀螺儀、文件系統等,業務能力如上傳下載、二維碼、地圖、支付、語音輸入、消息推送等。動畫

相關文章
相關標籤/搜索