function hideShare(){ callApp("showShare",0); } function showShare(){ alert("this is helloworld!"); } function onExit(){ callApp("onExit"); } function hideNav(){ callApp("showNav",0); } function showNav(){ callApp("showNav",1); } function uploadImage(){ var result = callApp("choosePhoto",6); alert(result); } function takePhoto(){ var result = callApp("takePhoto","{username:'wang'}"); //alert(result); } function getLocation(){ var result = callApp("getCurrentLocation"); alert(result); } function callApp(method) { var args = [].slice.call(arguments).splice(1); var s = ""; if (/android/i.test(navigator.userAgent) || /linux/i.test(navigator.userAgent)) {//安卓 s = window["auth"][method].apply(window.auth, args); } if (/ipad|iphone|mac/i.test(navigator.userAgent)) {//ios s = window["auth"][method].apply(this, args); } return s; } function jsAlert(){ alert("setTimeout"); } setTimeout("hideShare()",1000);