下面是列表页面mylist.html的全部代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet" />
<script type="text/javascript" charset="utf-8">
mui.init();
//初始化预加载详情页面
mui.init({
preloadPages: [{
id: 'detail.html',
url: 'detail.html'
}]
});
mui.plusReady(function() {
var detailPage = null;
//添加列表项的点击事件
mui('.mui-content').on('tap', 'a', function(e) {
var id = this.getAttribute('id');
//获得详情页面
if (!detailPage) {
detailPage = plus.webview.getWebviewById('detail.html');
}
//触发详情页面的newsId事件
mui.fire(detailPage, 'newsId', {
id: id
});
//打开详情页面
mui.openWindow({
url:'detail.html',
id: 'detail.html',
styles: {
top: '48px', //mui标题栏默认高度为48px;
bottom: '56px' //默认为0px,可不定义;
}
});
});
})
</script>
</head>
<body>
<div class="mui-content">
<a id="a1">a111111111111111111</a>
<br />
<br />
<a id="a2">a222222222222222222</a>
<br />
<br />
<a id="a3">a3333333333333333333</a>
<br />
<br />
</div>
</body>
</html>
下面是详细页面'detail.html'的全部代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet" />
<script type="text/javascript" charset="utf-8">
mui.init();
mui.plusReady(function() {
//添加newId自定义事件监听
window.addEventListener('newsId', function(event) {
var yid = event.detail.id;
alert(yid);
GetBaiduHtml(yid);
});
//ajax的请求方法用于测试
function GetBaiduHtml(id) {
alert('sss'+id);
mui.ajax('http://www.baidu.com', {
data: {
newsid: id
},
dataType: 'html', //服务器返回json格式数据
type: 'get', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
alert(data);
alert(document.getElementById("jxyinfo").innerHTML.length);
document.getElementById("jxyinfo").innerHTML = data;
alert(document.getElementById("jxyinfo").innerHTML.length);
},
error: function(xhr, type, errorThrown) {
console.log(type);
}
});
}
})
</script>
</head>
<body>
<div class="mui-content">
我的测试
<div id="jxyinfo">
ss
</div>
</div>
</body>
</html>
易数网络
好的 非常感谢 我在android 框架下进行的测试,我这就把代码贴出来
2015-01-15 16:39