分享到微博代码,添加分享窗口关闭回调
Posted Mr.Yongkang.Xu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了分享到微博代码,添加分享窗口关闭回调相关的知识,希望对你有一定的参考价值。
<html>
<head>
<title>
分享到微博代码,添加窗口关闭回调
</title>
</head>
<body>
<div id="click">分享到微博</div>
<script>
var shareWindow;//分享窗口
document.getElementById("click").onclick = function () {
var url = ‘http://www.baidu.com‘;
var content = ‘test‘;
var img = ‘http://jidian-php-prod.oss-cn-hangzhou.aliyuncs.com/kinder-choc161108/static/photo/3941639e4102cfd730f5f0b882cc4b781478943874.jpeg‘;
var appkey = ‘‘;
shareToWeibo(url, content, img, appkey, function () {
var loop = setInterval(function () {
if (shareWindow.closed) {
clearInterval(loop);
alert(‘closed‘);
}
}, 1000);
});
};
function shareToWeibo(url, content, img, appkey, callback) {
callback = callback || function () {};
javascript:void((function (s, d, e) {
var f = ‘http://v.t.sina.com.cn/share/share.php?‘;
var p = [‘url=‘ + e(url), ‘&title=‘, e(content), ‘&appkey=‘ + appkey].join(‘‘);
if (img !== false) {
p += ‘&pic=‘ + img;
}
function a() {
shareWindow = window.open([f, p].join(‘‘), ‘mb‘, [‘toolbar=0,status=0,resizable=1,width=620,height=450,left=‘, (s.width - 620) / 2, ‘,top=‘, (s.height - 450) / 2].join(‘‘))
if (!shareWindow) {
}
}
if (/Firefox/.test(navigator.userAgent)) {
setTimeout(a, 0);
} else {
a();
}
callback();
})(screen, document, encodeURIComponent));
}
</script>
</body>
以上是关于分享到微博代码,添加分享窗口关闭回调的主要内容,如果未能解决你的问题,请参考以下文章