plus.webview.getWebviewById('为页面设置的id值');
复制代码
plus.webview.currentWebview();
复制代码
var ws=plus.webview.currentWebview();//获取当前页面所属的Webview窗口对象
console.log( "窗口标识: "+ws.id );
console.log( "当前Webview窗口:"+ws.getURL() );
复制代码
plus.webview.currentWebview().opener();
复制代码
plus.webview.all();
复制代码
plus.webview.getTopWebview();
复制代码
注意:方法要写在plusready方法内部html
document.addEventListener("plusready", onPlusReady, false);
function onPlusReady(){
var curr = plus.webview.currentWebview(); //获取当前页面
var wvs = []; //空数组用来储存已经获取的窗口
if(plus.webview.getWebviewById('my_vip0.html')){
//首先判断该页面否已经打开不然不添加
wvs.push(plus.webview.getWebviewById('my_vip0.html'));
}
if(plus.webview.getWebviewById('my_vip1.html')){
//首先判断该页面否已经打开不然不添加
wvs.push(plus.webview.getWebviewById('my_vip1.html'));
}
if(plus.webview.getWebviewById('my_vip2.html')){
//首先判断该页面否已经打开不然不添加
wvs.push(plus.webview.getWebviewById('my_vip2.html'));
}
console.log(wvs);
for (var i = 0,len = wvs.length; i < len; i++) {
//关闭除当前页面外的其余页面
//关闭方法一
if (wvs[i].getURL() != curr.getURL()){
plus.webview.close(wvs[i],"none");
}
//关闭除指定页面外的其余页面
//key 能够是指定页面名称或者其余关键字
//关闭方法二
if (wvs[i].getURL().indexOf("Key") == -1){
plus.webview.close(wvs[i]);
}
}
}
复制代码