js和移动端交互

1、js和移动端交互

移动端打开wap页面,点击某按钮以后可返回一下代码:

var ua = navigator.userAgent.toLowerCase();
if (/iphone|ipad|ipod/.test(ua)) {
 
 
   var result = {"action":"close"}
   
 webkit.messageHandlers.ylcm.postMessage(JSON.stringify(result));
}else if(/android/.test(ua)) {
   var result = {"action":"close"}
    window.jsObj.HtmlcallJava(JSON.stringify(result));
}

2、移动端和js交互

移动端和js交互比较简单,直接调用wap端中定义的js函数即可

function upload_start(id){
    alert(id)
}

猜你喜欢

转载自blog.csdn.net/q490880/article/details/79288653