JS调用native的HTML代码示例:
<script type="text/javascript">
var toHome = function(){
if (typeof(android)=='undefined')
window.webkit.messageHandlers.nativeToHome.postMessage('');
else
android.toHome();
}
var share = function(shareinfo){
if (typeof(android)=='undefined'){
window.webkit.messageHandlers.nativeShare.postMessage(shareinfo)
} else {
android.share(shareinfo)
}
}
</script>
native调用JS 有返回值的代码示例:
<script type="text/javascript">
var shareinfo = JSON.stringify({
title: '多品类多列商品测试',
link: 'http://wow.mxth.com/shopping/acti_special.htm?id=18',
desc: '多品类多列商品测试',
imgUrl: 'http://wx.qlogo.cn/mmopen/Q3auHgzwzM5dVJKFHZMnL4fCCwBibQgByD2hgt3ydKTDg0sn9PZASRCibhIJfoVayLn2BaIyo443Z4RGuTtIER4Q/0'});
function wxshare(){
if (typeof(android)!='undefined'){
android.actishare(shareinfo);
return;
}
return shareinfo;
}
</script>