火狐 html5 退出 白屏,Html5+ 后退按钮出现白屏(webView.back会白屏)
您好,打包裝到 iPad 上去調(diào)試,A ->B 之后,第一次調(diào)用 webView.back 會顯示白屏,頁面切換使用的 webView.loadUrl ,代碼如下:
var sub = plus.webview.create(_basePath + 'pages/canlucate/canlucate.html', 'subpage-web', {
left: '80px',
right: '0px',
top: '55px',
bottom: '0px',
popGesture: 'none',
scrollIndicator: 'none'
});
plus.webview.currentWebview().append(sub);
mui('.mui-bar ul').on('tap', 'li', function() {
var href = this.getAttribute('data-href');
if(sub.getURL() != href) {
sub.loadURL(_basePath + href);
} else {
sub.show();
}
switchMenu(href);
});
/**
* 注冊頁面切換事件
*/
window.addEventListener('loadUrl', function(e) {
var url = e.detail.url;
if(sub.getURL() != url) {
sub.loadURL(_basePath + url);
} else {
sub.show();
}
switchMenu(url);
});
/**
* 注冊頁面回退事件
*/
window.addEventListener('goBack', function(e) {
sub.canBack(function(e) {
if(e.canBack) {
sub.back();
switchMenu(sub.getURL());
}
});
});
這里是頁面JS
//鏈接跳轉(zhuǎn)
var mainWebView;
function goUrl(url,id,options){
if(url.startWith('http://') || url.startWith('https://')){
if(mui.os.plus){
plus.runtime.openURL(url);
}else{
mui.openWindow(url);
}
return;
}
if(url.indexOf('.html') == -1){ //不包含 .Html 后綴
if(url.lastIndexOf('?') != -1){//Url中包含有參數(shù)
url = url.substring(0,url.lastIndexOf('?')) + '.html'+url.substring(url.lastIndexOf('?'));
}else{ //Url 不包含參數(shù)
url += '.html';
}
}
if(!mainWebView){
mainWebView = plus.webview.currentWebview().parent();
}
mui.fire(mainWebView,'loadUrl',{url: url});
}
返回
/**
* 返回上一頁
*/
function goBack(){
mui.back();
}
mui.back = function(){
if(!mainWebView){
mainWebView = plus.webview.currentWebview().parent();
}
mui.fire(mainWebView,'goBack');
}
附件是測試Demo,煩請看下,謝謝,測試流程 ,左側(cè)導(dǎo)航欄 客戶--》客戶列表--》點擊某一個客戶--》點擊左上角返回按鈕
總結(jié)
以上是生活随笔為你收集整理的火狐 html5 退出 白屏,Html5+ 后退按钮出现白屏(webView.back会白屏)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 删除a标签下面的横线
- 下一篇: mysql业务数据库回退_理解MySQL