微信官方文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115
方法一: 加一段js代码
WeixinJSBridge 是微信浏览器内部私有接口
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
WeixinJSBridge.call('hideOptionMenu');
});
方法二: 初始化JSSDK
hideMenuItems 隐藏需要的菜单项.可以进行配置 数组的形式
方法二:设置微信jssdk
wx.config({
debug: false,
appId: 'appid',
timestamp: timestamp,
nonceStr: 'nonceStr',
signature: 'signature',
jsApiList: ['hideMenuItems',]
});
wx.ready(function(){
wx.hideMenuItems({
menuList: ['menuItem:share:appMessage',"menuItem:share:timeline"]
});
})
方法三: 初始化JSSDK配置
hideOptionMenu 隐藏所有的菜单项--和上一个对比这个 是隐藏所有选项.
wx.config({
debug: false,
appId: 'appid',
timestamp: timestamp,
nonceStr: 'nonceStr',
signature: 'signature',
jsApiList: ['hideOptionMenu',]
});
wx.ready(function(){
wx.hideOptionMenu()
})
关闭微信内部浏览器
这个方法就是关闭微信自带的浏览器页面
WeixinJSBridge.call('closeWindow');
实现:您必须使用微信内置浏览器访问本页面! 的功能
$(function () {
var useragent = navigator.userAgent;
if (useragent.match(/WindowsWechat/) == 'WindowsWechat' || useragent.match(/MicroMessenger/i) != 'MicroMessenger') {
alert('已禁止本次访问:您必须使用微信内置浏览器访问本页面!');
$("body").empty();
document.head.innerHTML = '
document.body.innerHTML = '
请在微信客户端打开链接
}
});