Web 项目中分享到微博、QQ空间等分享功能

2022-10-22,,,,

Web 项目分享到微博、QQ空间等分享功能

网上有很多的模板以及代码,但是有很多都不能分享内容,简单的测试了下:

以新浪微博为例,文本框中的内容是title属性,下面的链接是url属性,如果你的链接页面有图片,会自动抓取图片让你选择,因此,当你自己写分享功能时需要你传递title和url属性到接口链接即可。

代码如下:

 <script>
function buttonShare(url){
$("#theForm").attr("action",url);
$("#theForm").submit();
}
</script>
<body>
<div>
<a href="../front/login.htm">登录</a>
<form action="" id="theForm">
<input id="title" name="title" value="测试">
<input id="img" name="img" value="test1">
<input id="url" name="url" value="http://image.baidu.com/">
<span id="buttonShare" onclick="buttonShare('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey')"><img src="http://static.youku.com/v1.0.0691/v/img/ico_Qzone.gif" /></span>
<span id="buttonShare" onclick="buttonShare('http://share.renren.com/share/buttonshare.do')"><img src="http://static.youku.com/v1.0.0691/v/img/ico_renren.gif" /></span>
<span id="buttonShare" onclick="buttonShare('http://v.t.sina.com.cn/share/share.php?appkey=2684493555')"><img src="http://static.youku.com/v1.0.0691/v/img/ico_sina.gif" /></span>
<span id="buttonShare" onclick="buttonShare('http://www.douban.com/recommend/')"><img src="http://static.youku.com/v1.0.0691/v/img/ico_dou_16x16.png" /></span>
</form> </div>
</body>

Web 项目中分享到微博、QQ空间等分享功能的相关教程结束。

《Web 项目中分享到微博、QQ空间等分享功能.doc》

下载本文的Word格式文档,以方便收藏与打印。