腾讯微博转播

<a href="javascript:;" class="tmblog" id="share_btn_1331450456228"><img src="http://v.t.qq.com/share/images/s/b24.png" border="0" alt="转播到腾讯微博"></a>

<script>
var _share_tencent_weibo=function(){String.prototype.elength=function(){return this.replace(/[^\u0000-\u00ff]/g,"aa").length};String.prototype.tripurl=function(){return this.replace(new RegExp("((news|telnet|nttp|file|http|ftp|https)://){1}(([-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)*(\\.[-A-Za-z]{2,5}))|([0-9]{1,3}(\\.[0-9]{1,3}){3}))(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*)*","gi"),new Array(12).join("aa"))};if(!!window.find){HTMLElement.prototype.contains=function(B){return this.compareDocumentPosition(B)-19>0}};var _appkey="801109086"||"801000271";var _web={"name":document.title||"","href":location.href.replace(/([^\x00-\xff]+)/g,encodeURIComponent("$1")),"hash":location.hash,"target":"toolbar=0,status=0,resizable=1,width=630,height=530"};var _pic=function(area){var _imgarr=area.getElementsByTagName("img");var _srcarr=[];for(var i=0;i<_imgarr.length;i++){if(_imgarr[i].width<50||_imgarr[i].height<50){continue;}_srcarr.push(encodeURIComponent(_imgarr[i].src))}return _srcarr.join("|")};var _text=function(){var s1=arguments[0]||"",s2=Array().slice.call(arguments,1).join(" ").replace(/[\s\n]+/g," "),k=257-s1.tripurl().elength();var s=s2.slice(0,(k-4)>>1);if(s2.elength()>k){k=k-3;for(var i=k>>1;i<=k;i++){if((s2.slice(0,i)).tripurl().elength()>=k){break}else{s=s2.slice(0,i)}}s+="..."}else{s=s2}return[s1,s]};var _u="http://share.v.t.qq.com/index.php?c=share&a=index&f=q2&url=$url$&appkey="+_appkey+"&assname=&title=$title$&pic=$pic$";var qshare_btn=function(_arr){if(_arr[0]){return _arr[0]}else{var o=document.createElement("a"),_ostyle="width:92px;height:22px;background:url(http://mat1.gtimg.com/app/opent/images/websites/qshare/icon.gif);position:absolute;display:none;";o.setAttribute("style",_ostyle);o.style.cssText=_ostyle;o.setAttribute("href","javascript:;");document.body.insertBefore(o,document.body.childNodes[0]);return o}}(arguments);var share_area=function(_arr){if(_arr[1]){if((typeof _arr[1]=="object"&&_arr[1].length)||(_arr[1].constructor==Array)){return _arr[1]}else{return[_arr[1]]}}else{return[document.body]}}(arguments);var current_area=share_area[0];var share_btn=function(_arr){if(_arr[2]){_arr[2].onclick=function(){window.open(_u.replace("$title$",encodeURIComponent(_text(_web.name,"").join(" "))).replace("$url$",encodeURIComponent(_web.href)).replace("$pic$",_pic(share_area[0])).substr(0,2048),'null',_web.target)}}else{return null}}(arguments);var _select=function(){return(document.selection?document.selection.createRange().text:document.getSelection()).toString().replace(/[\s\n]+/g," ")};var show=function(e,x,y){with(qshare_btn.style){display="inline-block";left=x+"px";top=y+"px";position="absolute";zIndex="999999"}};var hide=function(e){e.style.display="none"};document.onmouseup=function(e){e=e||window.event;var o=e.target||e.srcElement;for(var i=0;i<share_area.length;i++){if(share_area[i].contains(o)||share_area[i]==o){var _e={"x":e.clientX,"y":e.clientY};var _o={"w":qshare_btn.clientWidth,"h":qshare_btn.clientHeight};var _d=window.pageYOffset||(document.documentElement||document.body).scrollTop||0;var x=(_e.x-_o.w<0)?_e.x+_o.w:_e.x-_o.w,y=(_e.y-_o.h<0)?_e.y+_d-_o.h:_e.y+_d;if(_select()&&_select().length>=10&&o!=qshare_btn){show(qshare_btn,x-5,y);current_area=share_area[i];break}else{hide(qshare_btn)}}else{hide(qshare_btn)}}};document.onmouseover=function(e){var curtarget=(e&&e.target)||(window.event&&window.event.srcElement),sx=parseInt(qshare_btn.style.width),sy=parseInt(qshare_btn.style.height),d=Math.min(sx,sy);if(curtarget.tagName.toLowerCase()=="img"){var erect=curtarget.getBoundingClientRect();if(curtarget.clientWidth>=150&&curtarget.clientHeight>=150){show(share_btn,erect.right-sx-d,erect.bottom+document.body.scrollTop+document.documentElement.scrollTop-sy-d);qshare_btn.setAttribute("shareimg",curtarget.src)}}else if(curtarget!=qshare_btn&&qshare_btn.getAttribute("shareimg")){qshare_btn.removeAttribute("shareimg");hide(qshare_btn);}};document.onmousedown=function(e){var curtarget=(e&&e.target)||(window.event&&window.event.srcElement);if(curtarget!=qshare_btn){if(document.selection){document.selection.empty()}else if(window.getSelection){window.getSelection().removeAllRanges()}}};qshare_btn.onclick=function(){var shareimg=qshare_btn.getAttribute("shareimg");if(shareimg!=null){window.open(_u.replace("$title$",encodeURIComponent(_web.name+" ")).replace("$url$",encodeURIComponent(_web.href)).replace("$pic$",encodeURIComponent(shareimg)).substr(0,2048),'null',_web.target);return}var _str=_select();_resultstr=_text(_web.name,_str).reverse().join(" ");if(_str){var url=_u.replace("$title$",encodeURIComponent(_resultstr+" ")).replace("$pic$",_pic(current_area));url=url.replace("$url$",encodeURIComponent(_web.href.replace(_web.hash,"")+"#"+(current_area["name"]||current_area["id"]||""))).substr(0,2048);window.open(url,'null',_web.target)}hide(this)}};_share_tencent_weibo(null,null,document.getElementById("share_btn_1331450456228"));
</script>

猜你喜欢

转载自jiangkan12.iteye.com/blog/1450221