html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
分享测试标题:
简介:
var imgUrl = 'http://www.p-roy.com/object/images/at0591wechattx.jpg';
var lineLink = 'http://www.p-roy.com/fe/2014-09/23-386.html';
var descContent = "微信链接分享简介";
var shareTitle = '微信分享标题';
var appid = 'wxffaafd4668aaa1d2'; //可为空
//实现点击按钮后改变分享标题
var oBtn1 = document.getElementById('btn1');
oBtn1.onclick = function()
{
descContent = document.getElementById('content').value;
shareTitle = document.getElementById('title').value;
}
function shareFriend() {
WeixinJSBridge.invoke('sendAppMessage',{
"appid": appid,
"img_url": imgUrl,
"img_width": "640",
"img_height": "640",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function(res) {
_report('send_msg', res.err_msg);
})
}
function shareTimeline() {
WeixinJSBridge.invoke('shareTimeline',{
"img_url": imgUrl,
"img_width": "640",
"img_height": "640",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function(res) {
_report('timeline', res.err_msg);
});
}
function shareWeibo() {
WeixinJSBridge.invoke('shareWeibo',{
"content": descContent,
"url": lineLink,
}, function(res) {
_report('weibo', res.err_msg);
});
}
// 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
// 发送给好友
WeixinJSBridge.on('menu:share:appmessage', function(argv){
shareFriend();
});
// 分享到朋友圈
WeixinJSBridge.on('menu:share:timeline', function(argv){
shareTimeline();
});
// 分享到微博
WeixinJSBridge.on('menu:share:weibo', function(argv){
shareWeibo();
});
}, false);
直接复制代码另存为html文件即可。
测试网址:http://www.p-roy.com/object/images/at0591wechattx.jpg