新浪和QQ微博分享Js功能

<!DOCTYPE html>

<html>
	<head>
		<title>分享到</title>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	</head>
	<script type="text/javascript" src="http://liangjilong.duapp.com/jquery/jquery-1.4.2.js"></script>
	
</html> 
<body> 
	<div>
		<img alt="新浪微博分享" src="sina_share.gif" style="cursor: pointer;" onclick="share('sina');">
		<img alt="QQ微博分享" src="	qq_share.gif" style="cursor: pointer;" onclick="share('qq');">
		<span id="userNameId">可爱的孩子</span>
		</br>
		<img src="http://liangjilong.duapp.com/images/u/1.jpg" id="pic"/>
	</div>
	<script>
		function share(obj){
			var sinaShareURL="http://service.weibo.com/share/share.php?";//新浪URL
			var qqShareURL="http://share.v.t.qq.com/index.php?c=share&a=index&";//新浪URL
			var host_url=document.location; //host_url获取当前的路径
			var title=$("#userNameId").text();
			var pic=$("#pic").attr("src");//var pic2=document.getElementById("pic").src;
			var _URL;
			if(obj=="sina"){
				 _URL=sinaShareURL+"url="+host_url+"&title="+title+"&pic="+pic;//新浪
			}else if(obj=="qq"){
		 		_URL=qqShareURL+"url="+host_url+"&title="+title+"&pic="+pic;//QQ
			}
			//location.href=_URL;
			window.open(_URL);//重新打开一个新的窗体
		}
	</script>
</body>
 
 

 

 

<!DOCTYPE html>
<html>
<head>
    <!--分享到的文本内容就是这个title标签的内容-->
    <title>我可爱的豪哥子</title>
    <script charset="utf-8" async="" src="http://cbjs.baidu.com/js/log.js"></script>
    <link href="http://bdimg.share.baidu.com/static/css/bdsstyle.css?cdnversion=20130704" rel="stylesheet" type="text/css">
   <script src="http://bdimg.share.baidu.com/static/js/logger.js?cdnversion=384377"></script>
</head>

<body>
<div>
    <a href="#" target="_blank">
        <img src="http://liangjilong.duapp.com/images/u/1.jpg"  style="max-width:90%">
    </a>
</div>
</br>
<!-- 百度JS  Baidu Button BEGIN -->
<div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare">

<a class="bds_qzone"></a>
<a class="bds_tsina"></a>
<a class="bds_tqq"></a>
<a class="bds_renren"></a>
<a class="bds_t163"></a>
<a class="shareCount"></a>
<span class="bds_more">更多分享:</span>
</div>
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=4053665" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->

</br>
</br></br>

<!-- JiaThis Button BEGIN  加网- 中国最大的社会化分享按钮及分享代码提供商!-->
<a href="http://www.jiathis.com/share/" class="jiathis" target="_blank">
<img src="http://v2.jiathis.com/code/images/jiathis2.gif" border="0" id="jiathis_a" /></a>
<script type="text/javascript" src="http://v2.jiathis.com/code/jia.js" charset="utf-8"></script>



</br>
</br>
</br>
<!--
 <div id="ckepop" class='feixiangjias'> 
    <a href="javascript:" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到:</a> 
    <a class="jiathis_button_qzone">QQ空间</a> 
    <a class="jiathis_button_tsina">新浪微博</a> 
    <a class="jiathis_button_kaixin001">开心网</a> 
    <a class="jiathis_button_renren">人人网</a> 
    <a class="jiathis_button_baidu">百度收藏</a> 
    <a class="jiathis_button_douban">豆瓣</a> 
    <a class="jiathis_button_tqq">腾讯微博</a> 
</div> 
<script type="text/javascript" src="http://www.139cai.com/public/share.js" charset="utf-8"></script> 

-->

<!-- JiaThis Button END --> 

 </body>
</html>

 
新浪和QQ微博分享Js功能_第1张图片
 

你可能感兴趣的:(JavaScript)