分享到代码,新浪微博,腾讯微博,搜狐,开心,人人,可插入图片,文字介绍信息,自定义按钮



大家可以把代码copy下来,新建utf-8形式的jsp文件,然后运行一下。
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="http://wonengchuangzaoqij.blog.163.com/blog/<%=basePath%>">

    <title>这是我的分享到测试</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="http://wonengchuangzaoqij.blog.163.com/blog/styles.css">
    -->

  </head>
  
  <body> 
  <div class="cp_cen_top2_mc" ><p id="pdtName">uvi产品名称(拍卖ID)</p>
<p id="shortDesc">短评介绍</p>
                  <img src="http://img238.ph.126.net/PIa6prap2bYiYlrKcbGUhA==/2222807891085516869.jpg" width="445" height="313" id="midPdtpic"/><br />
                  <p id="longDesc">详细描述 </p>
                  <img src="http://img77.ph.126.net/87TtdgQxZHHyKnVjoX4Zag==/863002278595605936.gif" width="445" height="313" id="bigPdtpic"/><br />
    
    
     <br>
 </div>
    <br>
     <input type="button" value="腾讯微博分享" οnclick="qq()"/>
      <input type="button" value="开心网分享" οnclick="kaixin();" />
       <input type="button" value="搜狐微博分享" οnclick="souhu();" />
        <input type="button" value="人人分享" οnclick="renren();" />
        <input type="button" value="新浪微博分享" οnclick="sina();" />
      
      
      
        <script type="text/javascript">
     var name=document.getElementById("pdtName").innerText;
  var shortdes=document.getElementById("shortDesc").innerText;
  var longdes=document.getElementById("longDesc").innerText;
  var content=name+"     "+shortdes+":"+longdes;
  var picsrc='http://img238.ph.126.net/r4Eg96N6N3serITMaeJAjA==/2222807891085516884.jpg';//document.getElementById("midPdtpic").src;
var img="<img    src="http://wonengchuangzaoqij.blog.163.com/blog/+picsrc+">";


var contentimg=content+img;

   function qq(){
   var _t = encodeURI(content);
   var _url = encodeURI(document.location);
   var _appkey = encodeURI("appkey");//你从腾讯获得的appkey
   var _pic = encodeURI(picsrc);//(列如:var _pic='图片url1|图片url2|图片url3....)
   var _site = 'http://www.amssy.com';//你的网站地址
   var _u = 'http://v.t.qq.com/share/share.php?title='+_t+'&url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic;
 
   window.open( _u,'转播到腾讯微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
  }
   

function kaixin(){
var t=window.open("http://www.kaixin001.com/repaste/share.php?rtitle="+content.substring(0,76)+"&rurl="+location.href+"&rword="+location.href+"&rcontent="+encodeURIComponent(contentimg),"_blank","scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes"); 



     } 
     
     
     
     function souhu()
{
var s=window.screen;
var d=document;
var e=encodeURIComponent;
var r="";
var l="";
var p="";
var t="";
var z="";
var c="utf-8"
var f='http://t.sohu.com/third/post.jsp?';
var u=z||d.location;
var tit=e(t||content);
var p=['&url=',e(u),'&title=',tit,'&content=',c||'gb2312','&pic=',e(p||picsrc)].join('');
function a()
{
if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))
u.href=[f,p].join('');
 }

if(/Firefox/.test(navigator.userAgent))
setTimeout(a,0);
else a();
}
  /**现在只能支持分享连接,描述图片均没有*/
function renren()
{
   var s=window.screen;
   var d=document;
   var e=encodeURIComponent;

if(/renren\.com/.test(d.location))
   return;
 var f='http://share.renren.com/share/buttonshare?link=',u=d.location,l=content,p=[e(u),'&title=',e(l)].join('');
   function a()
   {var winform=window.open([f,p].join(''),'xnshare',['toolbar=0,status=0,resizable=1,width=626,height=436,left=',(s.width-626)/2,',top=',(s.height-436)/2].join

(''));
   if(!winform)

u.href=[f,p].join('');


    };
if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);
else a();


}

function sina()
{

var s=window.screen;
var d=document;
var e=encodeURIComponent;
try{}catch(e){}


var f='http://v.t.sina.com.cn/share/share.php?',u=d.location.href,p=['url=',e(u),'&title=',e

(content),'&pic=',encodeURIComponent(picsrc),'&appkey=1226626340'].join('');

function a()
{if(!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('')))u.href=[f,p].join('');

};

if(/Firefox/.test(navigator.userAgent))

{setTimeout(a,0)}else{a()}



}
    </script>
    
  </body>
</html>
补充一下:
人人网站分享图片文字是网站自动抓取的,把open中的url修改一下
"http://www.connect.renren.com/share/sharer?url=你的网站地址";
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值