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]);
}
}
}
複製代碼