我在列表页面A,获得了某行的id,将id传到了详情页面B,然后,详情页面,只需要将id作为页面的名称拼接成固定的“Htp://wwww.baidu.com/”+id+".html";显示在B页面中,哪位高手帮忙搞定?
我的代码如下
A页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>公司动态</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="../css/mui.min.css">
<script src="../js/mui.min.js"></script>
<script src="../js/updown.js"></script>
<script src="../js/notice.js"></script>
<script src="../js/app.js"></script>
<style>
html,body {
background-color: #efeff4;
}
</style>
<script>
</script>
</head>
<header class="mui-bar mui-bar-nav">
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">公司动态</h1>
</header>
</header>
<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view mui-table-view-chevron">
<li class=“mui-table-view-cell” ><a class="mui-navigate-right" id="2">公司新闻</a></li>
</ul>
</div>
</div>
</body>
<script>
mui.init({
preloadPages:[{
id:'notice.html',
url:'notice.html'
}
]
});
var detailPage = null;
//添加列表项的点击事件
mui('.mui-content').on('tap', 'a', function(e) {
var id = this.getAttribute('id');
//获得详情页面
if(!detailPage){
detailPage = plus.webview.getWebviewById('notice.html');
}
//触发详情页面的newsId事件
mui.fire(detailPage,'newsId',{
id:id
});
//打开详情页面
mui.openWindow({url:'notice.html', id:'notice.html'});
});
</script>
</html>
B页面(详情)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>通知通告</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="../css/mui.min.css">
<script src="../js/mui.min.js"></script>
<script src="../js/app.js"></script>
<style>
html,body {
background-color: #efeff4;
}
</style>
<script>
//添加newId自定义事件监听
mui.init();
var newsid;
window.addEventListener('newsId',function(event){
//获得事件参数
newsid = event.detail.id;
//根据id向服务器请求新闻详情
loaduu();
});
function loaduu(){
window.location.href="Htp://product.21-sun.com/proDetail/"+newsid+'.shtm';
}
</script>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">通知内容</h1>
</header>
<div class="mui-content">
</div>
</body>
</html>
各位请指教~(由于不能发外部链接:我已经将http改为Htp)
另外,发现这个列表的id只能传递一次,后面再点,就不传递了,不知道为什么?
还有如何在b页面显示header的前提下,加载外部的url
java民工 (作者)
谢谢指教~~
2014-12-08 14:42