k***@163.com
k***@163.com
  • 发布:2017-07-14 18:01
  • 更新:2017-07-14 18:01
  • 阅读:996

外链返回问题

分类:HTML5+

需要实现的效果:首页点击搜索跳转到百度,在百度搜索操作完,按返回一直后退到百度首页,再按返回回到首页.html。
现在的效果:返回直接退出了。我下面的代码对吗?或者有没案例可以参考的。

首页.html 代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximumscale=1.0,user-scalable=no"/>
<script type="text/javascript">
function plusReady(){
ws=plus.webview.currentWebview();
// 预创建新窗口(显示在可视区域外)
wn=plus.webview.create('搜索.html', 'newdrag', {left:'100%',render:'always'});
wn.show('none');
// 右滑隐藏新窗口
wn.drag({direction:'right',moveMode:'followFinger'}, {view:ws,moveMode:'follow'}, function(e){
console.log('Right drag event: '+JSON.stringify(e));
});
}

if(window.plus){
plusReady();
}else{
document.addEventListener("plusready",plusReady,false);
}

function create(){
plus.webview.startAnimation({view:ws,styles:{fromLeft:'0%',toLeft:'-100%'},action:'none'},
{view:wn,styles:{fromLeft:'100%',toLeft:'0%'},action:'none'},
function(e){
console.log('Animation finished: '+JSON.stringify(e));
});
}
</script>
</head>
<body>
<botton onclick="create()">搜索</botton>
</body>
</html>

搜索.html 代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>Webview Example</title>
<script type="text/javascript">
var embed=null;
// H5 plus事件处理
function plusReady(){
embed=plus.webview.create("http://www.baidu.com","",{top:"46px",bottom:"0px"});
plus.webview.currentWebview().append( embed );
}

if(window.plus){
plusReady();
}else{
document.addEventListener("plusready",plusReady,false);
}

// 返回上次页面

function goBack() {

embed.back();

}

// 前进到上次页面

function goForward() {

embed.forward();

}

</script>

</head>

<body>

后退到上次加载的页面

<button onclick="goBack()">Back</button>

<button onclick="goForward()">Forward</button>

</body>

</html>

2017-07-14 18:01 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复