在h5中跳转外部链接时,直接打开链接跳转外部页面成功后,后退会出现多退一级问题。
解决方法:新建一个空白html页面,放入以下打开新窗口代码,就能解决多退一级这个bug了。
mui.plusReady(function() {
var urls = "你要打开的网址";
var ws = plus.webview.currentWebview();
var topoffset = '45px';
if(plus.navigator.isImmersedStatusbar()) { // 兼容immersed状态栏模式
topoffset = (Math.round(plus.navigator.getStatusbarHeight()) + 45) + 'px';
}
var embed = plus.webview.create(urls, 'embed', {
top: topoffset,
bottom: '0px'
}); //创建页面
ws.append(embed);
embed.addEventListener('loaded', function() { //监听页面,当页面加载完成时
plus.nativeUI.closeWaiting();
}, false);
embed.addEventListener('loading', function() { //监听页面,当页面加载时
plus.nativeUI.showWaiting('', {
style: 'black',
modal: false,
background: 'rgba(0,0,0,0)'
});
}, false);
})