隐藏微信中网页右上角按钮
function onBridgeReady(){ WeixinJSBridge.call('hideOptionMenu'); } if (typeof WeixinJSBridge == "undefined"){ if( document.addEventListener ){ document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false); }else if (document.attachEvent){ document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady); } }else{ onBridgeReady(); } //返回说明 //隐藏底部导航栏没有返回值。(需要显示请把hideOptionMenu换成showOptionMenu)
隐藏微信中网页底部导航栏
function onBridgeReady(){ WeixinJSBridge.call('hideToolbar'); } if (typeof WeixinJSBridge == "undefined"){ if( document.addEventListener ){ document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false); }else if (document.attachEvent){ document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady); } }else{ onBridgeReady(); } //返回说明 //隐藏底部导航栏没有返回值。(需要显示顶部导航栏,请把hideToolbar换成showToolbar)
网页获取用户网络状态
function onBridgeReady(){ WeixinJSBridge.invoke('getNetworkType',{}, function(e){ WeixinJSBridge.log(e.err_msg); }); } if (typeof WeixinJSBridge == "undefined"){ if( document.addEventListener ){ document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false); }else if (document.attachEvent){ document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady); } }else{ onBridgeReady(); } //返回说明 //获取用户网络状态的返回值如下: //network_type:wifi wifi网络 //network_type:edge 非wifi,包含3G/2G //network_type:fail 网络断开连接 //network_type:wwan(2g或者3g)
关闭当前网页窗口
WeixinJSBridge.invoke('closeWindow',{},function(res){ //alert(res.err_msg); }); //关闭成功返回“close_window:ok”,关闭失败返回“close_window:error”
关闭当前浏览器内置函数:WeixinJSBridge.call('closeWindow');
微信官方地址