通过mui的ajax请求是可以实现跨域的。
跨域是浏览器安全里的一个名词。记住了 是浏览器。
而我们的是app,请求并不是走浏览器脚本,而是用的H5+底层请求的。所以不存在什么跨域。直接调用。
===========获取应用入口页面的方法======================
var h=plus.webview.getWebviewById( plus.runtime.appid );
console.log( "应用首页Webview窗口:"+h.getURL() );
==========判断plus对象是否生效=======================
if(window.plus){
plusReady();
}else{
document.addEventListener("plusready",plusReady,false);
}
============获取上一页(获取父页面)的方法==============================
var preUrl = plus.webview.currentWebview().opener().getURL();
console.log(preUrl);
===========双击回退按钮后关闭app的方法==========================
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
mui.back = function() {
//首次按键,提示‘再按一次退出应用’
if (!first) {
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function() {
first = null;
}, 1000);
} else {
if (new Date().getTime() - first < 1000) {
plus.runtime.quit();
}
}
};
============手机网络状态========================================
document.addEventListener( "netchange", function() {
var network = plus.networkinfo.getCurrentType();
if(network < 2) {
if(this.network > 1) {
plus.nativeUI.toast('您的网络已断开', undefined, '期待乐');
}
}
if(this.network == 3 && network > 3) {
plus.nativeUI.toast('您网络已从wifi切换到蜂窝网络,浏览会产生流量', undefined, '期待乐', '我知道了');
}
this.network = network;
});
==========手机回退键的触发======================================
function plusReady(){
ws=plus.webview.currentWebview();
// Android处理返回键
plus.key.addEventListener('backbutton',function(){
back();
},false);
compatibleAdjust();
}
=============有选择项的提示框==========
//