android+webview+打不开,webview 在android下无法打开 ?是否为一个bug?请帮忙看下!谢谢!...
android 平臺上(已經試過 nexus 5 , samsung s6等三個機型),如果先點擊右邊的圖標打開預加載好的webview, 順利滑出;但是不管之后還是之前,如果打開過左邊的webview(drawer 效果)之后,再點擊右邊圖標想打開右邊的webview,就完全打不開,主窗口也沒有移動,只出現了一個半透明的mask,但是 左邊的窗口和drawer效果,毫無影響,從頭到尾都可以順利彈出。請幫我看看是什么問題?代碼見下:
var leftDrawer=null,rightDrawer=null,rootWindow=null;
var leftDrawerStatus=false, rightDrawerStatus=false;
var isLeftInTransition=false,isRightInTransition=false;
mui.plusReady(function(){
plus.screen.lockOrientation('portrait-primary');
rootWindow=plus.webview.currentWebview();
rootWindow.addEventListener('maskClick',function(){
if(leftDrawerStatus){
closeLeftDrawer();
}
else{
closeRightDrawer();
}
});
setTimeout(function(){
leftDrawer=mui.preload({
id:'leftDrawer',
url:'leftDrawer.html',
styles:{
left:0,
top:0,
width:'70%',
zindex:-1
},
show:{
aniShow:'none'
}
});
rightDrawer=mui.preload({
id:'rightDrawer',
url:'rightDrawer.html',
styles:{
right:0,
top:0,
width:'70%',
zindex:-1
},
show:{
aniShow:'none'
}
});
},200);
function openLeftDrawer(){
if(isLeftInTransition){
return ;
}
if(!leftDrawerStatus){
isLeftIntransition=true;
leftDrawer.setStyle({
mask: 'rgba(0,0,0,0)'
});
leftDrawer.show('none', 0, function() {
rootWindow.setStyle({
mask: 'rgba(0,0,0,0.4)',
left: '70%',
transition: {
duration: 150
}
});
mui.later(function() {
isLeftInTransition = false;
leftDrawer.setStyle({
mask: "none"
});
}, 160);
leftDrawerStatus = true;
});
}
};
function openRightDrawer(){
if(isRightInTransition){
return ;
}
if(!rightDrawerStatus){
isRightInTransition=true;
rightDrawer.setStyle({
mask: 'rgba(0,0,0,0)'
});
rightDrawer.show('none', 0, function() {
rootWindow.setStyle({
mask: 'rgba(0,0,0,0.4)',
right: '70%',
transition: {
duration: 150
}
});
mui.later(function() {
isRightInTransition = false;
rightDrawer.setStyle({
mask: "none"
});
}, 160);
rightDrawerStatus = true;
});
}
};
function closeLeftDrawer() {
if (isLeftInTransition) {
return;
}
if (leftDrawerStatus) {
isLeftInTransition = true;
rootWindow.setStyle({
mask: 'none',
left: 0,
transition: {
duration: 200
}
});
leftDrawerStatus = false;
mui.later(function() {
isLeftInTransition = false;
leftDrawer.hide();
}, 300);
}
};
function closeRightDrawer() {
if (isRightInTransition) {
return;
}
if (rightDrawerStatus) {
isRightInTransition = true;
rootWindow.setStyle({
mask: 'none',
right: 0,
transition: {
duration: 200
}
});
rightDrawerStatus = false;
mui.later(function() {
isRightInTransition = false;
rightDrawer.hide();
}, 300);
}
};
document.querySelector('#leftDrawer').addEventListener('tap',function(e){
if(leftDrawerStatus){
closeLeftDrawer();
}
else{
openLeftDrawer();
}
});
document.querySelector('#rightDrawer').addEventListener('tap',function(e){
if(rightDrawerStatus){
closeRightDrawer();
}
else{
openRightDrawer();
}
});
});
感謝!
總結
以上是生活随笔為你收集整理的android+webview+打不开,webview 在android下无法打开 ?是否为一个bug?请帮忙看下!谢谢!...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android中布局全屏,怎么在Andr
- 下一篇: 用html可以写游戏,javascrip