|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content='True' name='HandheldFriendly' />
<title></title>
<script src="res/js/zepto.js"></script>
<script src="res/js/sendmsg.js"></script>
</head>
<body>
<script type="text/javascript">
//WadeMobile.tip("你好,我好,大家好………………");
</script>
<h1>跨域调用</h1>
<button style="width:200px;height:100px;" id="openContacts">打开联系人(无回调)</button>
<script type="text/javascript">
/* alert('child alert'); */
var btn = document.getElementById("openContacts");
btn.onclick = function(){
//WadeMobile.openBrowser("http://3g.baidu.com");
var msg = {
objName : "wadeMobile",
method : "getContacts",
paras : [function(result){
alert(result.toString())
}]
}
sendMsg(msg);
}
</script>
<br /><br />
<button style="width:200px;height:100px;" id="openBrowser">打开浏览器(无回调)</button>
<script type="text/javascript">
/* alert('child alert'); */
var btn = document.getElementById("openBrowser");
btn.onclick = function(){
var msg = {
objName:"wadeMobile",
method:"openBrowser",
paras:["http://3g.baidu.com"]
}
sendMsg(msg);
}
</script>
<br /><br />
<button style="width:200px;height:100px;" id="getImei">获取手机IMEI号(回调)</button>
<script type="text/javascript">
var btn = document.getElementById("getImei");
btn.onclick = function(){
var msg = {
objName : "wadeMobile",
method : "getSysInfo",
paras : [ function(name) {
alert('手机IMEI号:'+name);
}, 'IMEI', function(name, t){
alert("callback error");
}]
};
sendMsg(msg);
}
</script>
<br /><br />
<button style="width:200px;height:100px;" id="setMemoryCache">设置缓存</button>
<script type="text/javascript">
var btn = document.getElementById("setMemoryCache");
btn.onclick = function(){
var msg = {
objName:"wadeMobile",
method:"setMemoryCache",
paras:["Key001","我是缓存中的测试值-Value001"]
};
sendMsg(msg);
}
</script>
<br /><br />
<button style="width:200px;height:100px;" id="getMemoryCache">获取缓存</button>
<script type="text/javascript">
var btn = document.getElementById("getMemoryCache");
btn.onclick = function(){
var msg = {
objName:"wadeMobile",
method:"getMemoryCache",
paras:[function(value){
alert(value);},"Key001","没有取到值我,我是默认值"]
};
sendMsg(msg);
}
</script>
<!-- <br /><br />
<button style="width: 200px;height: 100px;" id="sendAjaxPost">发送Post请求</button>
<script type="text/javascript">
var btn = document.getElementById("sendAjaxPost");
btn.onclick = function(){
//创建XMLHttpRequest对象
xhr = new XMLHttpRequest();
//注册回调函数
xhr.onreadystatechange=callback;
//第一个参数设置成post,第二个写url地址,第三个为是否采用异步方式
xhr.open("POST","data",true);
//post请求需要自己设置请求头
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//post请求
xhr.send("name=lisi");
}
function callback(){
//接收响应数据
//判断对象状态是否交互完成,如果为4则交互完成
if(xhr.readyState == 4){
//判断对象状态是否交互成功,如果成功则为200
if(xhr.status == 200){
//接收数据,得到服务器输出的纯属文本数据
var response = xhr.responseText;
alert("返回的数据为:" + response);
}
}
}
</script>
<br /><br />
<button style="width:200px;height:100px;" id="goCustomerCentre">跳转到CustomerCentre</button>
<script type="text/javascript">
var btn = document.getElementById("goCustomerCentre");
btn.onclick = function(){
window.location.href="http://10.0.2.2:8080/start";
}
</script>
<br /><br />
<input type="text" style="width: 200px;height: 100px;"> -->
</body>
</html>
|