首页 > 代码库 > 微信接口

微信接口

<script type="text/javascript" src="http://www.mamicode.com/js/jquery-1.7.2.min.js"></script>
<script>
var imgUrl = "http://www.linzmei.com/2015newyear/3.jpg";

var lineLink = "http://www.linzmei.com/2015newyear";
var descContent = "2015 HAPPY NEW YEAR"; //分享给好友的时候显示标题和描述,分享到朋友圈只显示标题
var shareTitle = "2015 HAPPY NEW YEAR";
var appid = "";

var share = {
shareFriend: function () {
WeixinJSBridge.invoke(‘sendAppMessage‘, {
"appid": appid,
"img_url": imgUrl,
"img_width": "200",
"img_height": "200",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function (res) {
//_report(‘send_msg‘, res.err_msg);
})
},
//分享到朋友圈
shareTimeline: function () {
WeixinJSBridge.invoke(‘shareTimeline‘, {//
"img_url": imgUrl,
"img_width": "200",
"img_height": "200",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function (res) {
//_report(‘timeline‘, res.err_msg);
});
}
}


document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {//

//发送给好友
WeixinJSBridge.on(‘menu:share:appmessage‘, function (argv) {
share.shareFriend();
});
//分享到朋友圈
WeixinJSBridge.on(‘menu:share:timeline‘, function (argv) {
share.shareTimeline();
});

}, false);

 

 

 

</script>
<script type="text/javascript">
$(function()
{

var h = document.documentElement.clientHeight;//获取页面可见高度

$(".aaa").css("height",h);

//当浏览器窗口大小改变时,设置显示内容的高度

window.onresize=function(){
changeDivHeight();
}
function changeDivHeight(){
h = document.documentElement.clientHeight;//获取页面可见高度
$(".aaa").css("height",h);




}
})


</script>

 

<body>

<div style="height: 0px;"> <img height="0" width="0" src="http://www.mamicode.com/3.jpg"> </div>

 

</body>

 

微信接口