web端分享網頁到各個網站JS代碼(微信為生成二維碼)


/*分享到新浪微博,QQ空間,人人網,生成二維碼*/
    var myTitle=$("title").text();
    var myHref = window.location.href;
    function shareweibo(title,url,picurl)  
    {  
        var sharesinastring='http://v.t.sina.com.cn/share/share.php?title='+title+'&url='+url+'&content=utf-8&sourceUrl='+url+'&pic='+picurl;  
        window.open(sharesinastring,'newwindow','height=400,width=400,top=100,left=100');  
    }
    function sharetoqqzone(title,url,picurl)  
    {  
        var shareqqzonestring='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?summary='+title+'&url='+url+'&pics='+picurl;  
        window.open(shareqqzonestring,'newwindow','height=400,width=400,top=100,left=100');  
    }   
    function sharerenren(title,url,picurl){
        var shareqqzonestring='http://share.renren.com/share/buttonshare.do?link='+myHref+'&title='+myTitle+'';  
        window.open(shareqqzonestring,'newwindow','height=400,width=400,top=100,left=100');  
    }
    function sharewxcode() {
        var text ="北京高陽金信信息技術有限公司";
        //生成二維碼可能和網上其他地方的資料不一樣,添加了logo圖片路徑(之前不知道哪位高手寫的第一版本,貌似沒有logo功能,小弟在此基礎上加的)
        $('#div_code').qrcode({
            text: utf16to8(text),
            height: 200,
            width: 200,
            colorDark : '#000000',
            colorLight : '#ffffff',
            correctLevel : QRCode.CorrectLevel.H
          //此處添加了個logo,可以隨意替換鏈接
          /*src: 'file:///E:/test/erweima/images/123211.jpg'*/
      });
    }
    function utf16to8(str) { //轉碼
        var out, i, len, c;
        out = "";
        len = str.length;
        for (i = 0; i < len; i++) {
            c = str.charCodeAt(i);
            if ((c >= 0x0001) && (c <= 0x007F)) {
                out += str.charAt(i);
            } else if (c > 0x07FF) {
                out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
                out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            } else {
                out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            }
        }
        return out;
    }
    $("#weibo").click(function(){
        shareweibo(myTitle,myHref,"");
    });
    $("#qq").click(function(){
        sharetoqqzone(myTitle,myHref,"");
    });
    $("#weixin").click(function(){
        sharewxcode();
    });
    $(".cancel").click(function(){
        $("#div_code").empty();
    });
    $("#renren").click(function(){
        sharerenren();
    });

<script type="text/javascript" src="js/jquery-1.10.0.js"></script>
<script type="text/javascript" src="js/qrcode.js"></script>
<script type="text/javascript" src="js/jquery.qrcode.min.js"></script>

 或者直接用百度的JiaThis

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM