1.使用openApp调用浏览器,如果手机内有多个浏览器,会首先弹出选择浏览器的框,将url传过去,手机浏览器会自动打开。
2.使用openWin,直接打开网页,但是不显示地址栏(不能输入url),也不能返回,IOS下只能将app关闭。解决办法是,先打开win,win里面放入返回按钮,然后在win里面打开frame,frame的地址就是外部url(没有测试过)。
下面是两种方法代码,安卓在黑莓prive测试没问题,iOS在iPhone 6sp下没问题:
html代码:
<input type="button" onclick="openURLInApp()" value="在浏览器中打开我爱模板网"/> <input type="button" onclick="openURLInWin()" value="在app中打开我爱模板网"/>js代码:
//在浏览器中打开
function openURLInApp(){
//判断操作系统
if(api.systemType == 'android'){
//Android中的使用方法如下:
api.openApp({
androidPkg: 'android.intent.action.VIEW',
mimeType: 'text/html',
uri: 'https://5.jimth.com'
}, function(ret, err) {});
}else{
//iOS中的使用方法如下:
api.openApp({
iosUrl: 'https://5.jimth.com'
});
}
}
//在app内部打开
function openURLInWin() {
api.openWin({
name : 'win_show2',
url : 'https://5.jimth.com',
rect : {
x : 0,
y : 0,
}
})
}
