herionliu 2013-09-10
/* * 微博分享 */ (function () { //分享到腾讯微博 function postToQQWb() { var _t = encodeURI(document.title); var _url = encodeURI(document.location); var _appkey = encodeURI("appkey");//你从腾讯获得的appkey var _pic = encodeURI('');//(列如:var _pic='图片url1|图片url2|图片url3....) var _site = location.href;//你的网站地址 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'); } copyToClipboard = function (txt) { //txt = document.getElementById("show_data").value; if (window.clipboardData) { window.clipboardData.clearData(); window.clipboardData.setData("Text", txt); } else if (navigator.userAgent.indexOf("Opera") != -1) { window.location = txt; } else if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("您的firefox安全限制限制您进行剪贴板操作,请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试"); return false; } var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); if (!clip) return; var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); if (!trans) return; trans.addDataFlavor('text/unicode'); var str = new Object(); var len = new Object(); var str = Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString); var copytext = txt; str.data = copytext; trans.setTransferData("text/unicode", str, copytext.length * 2); var clipid = Components.interfaces.nsIClipboard; if (!clip) return false; clip.setData(trans, null, clipid.kGlobalClipboard); } }; var shareObj = { version: "1.0", url: function () { return encodeURIComponent(window.location.href); }, title: function () { return encodeURIComponent("#精彩不错过#Samsung GALAXY S4 zoom! 180°全景虚拟体验悠闲旅程、时尚盛典、激情现场、动感瞬间!还在等什么!快来体验吧~"); }, source: function () { return encodeURIComponent(""); }, content: function (b) { if (b) { return encodeURIComponent(document.getElementById(b).innerText); } else { return encodeURIComponent(""); } }, setid: function () { if (typeof (shareid) == "undefined") { return ""; } else { return shareid; } }, siteUrl: "", //复制 copy: function () { var flag = copyToClipboard(this.url); if (!flag) { alert("恭喜你,你已经成功将地址复制到剪贴板,请转发给你身边的好友吧!"); } }, //新浪微薄 tsina: function () { window.open('http://v.t.sina.com.cn/share/share.php?title=' + encodeURI(this.title()) + '&url=' + this.url() + '&source=' + this.source()); }, //MSN msn: function () { window.open('http://profile.live.com/badge/?title=' + encodeURI(this.title()) + '&url=' + this.url() + '&source=' + this.source()); }, //腾讯微博 tqq: function () { postToQQWb(); }, //人人网 renren: function () { window.open('http://share.renren.com/share/buttonshare.do?title=' + encodeURI(this.title()) + '&link=' + this.url() + '&source=' + this.source()); }, //开心网 kaixin: function () { window.open("http://www.kaixin001.com/repaste/share.php?rtitle=" + encodeURI(this.title()) + "&rurl=" + this.url() + "&rcontent=" + this.source()); }, //网易微博 t163: function () { window.open("http://t.163.com/article/user/checkLogin.do?title=" + encodeURI(this.title()) + "&link=" + this.url() + "&source=" + this.source() + '&info=' + this.title() + this.url()); }, //搜狐微博 tsohu: function () { void ( (function (s, d, e, r, l, p, t, z, c) { var f = 'http://t.sohu.com/third/post.jsp?', u = z || d.location, p = ['&url=', e(u), '&title=', e(t || d.title), '&content=', c || 'gb2312', '&pic=', e(p || '')].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(); })(screen, document, encodeURIComponent, '', '', '', '', '', 'utf-8') ); }, //百度空间 baidu: function () { window.open('http://apps.hi.baidu.com/share/?title=' + encodeURI(this.title()) + '&url=' + this.url() + '&source=' + this.source()); }, //百度i贴吧 baiduti: function () { window.open('http://tieba.baidu.com/i/sys/share?title=' + encodeURI(this.title()) + '&link=' + this.url() + '&source=' + this.source()); }, //豆瓣网 douban: function () { window.open("http://www.douban.com/recommend/?url=" + this.url() + "&title=" + encodeURI(this.title()) + '&source=' + this.source()); }, //QQ空间 qqzone: function () { window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + this.url() + "&title=" + encodeURI(this.title())); }, //飞信空间 feixin: function () { window.open('http://space.fetion.com.cn/api/share?title=' + encodeURI(this.title()) + '&url=' + this.url() + '&source=' + this.source()); }, //天涯社区 tianya: function () { window.open('http://co.tianya.cn/third/export/thirdLoginDiv.jsp?app_id=jiathis&ccTitle=' + encodeURI(this.title()) + '&ccUrl=' + this.url()); }, //51.com web51: function () { window.open('http://passport.51.com/passport.5p?strTitle=' + encodeURI(this.title()) + '&gourl=' + this.url()); } }; window.share = shareObj; })();