分类
信息技术

用浏览器书签分享网页到社交网络

JavaScript(JS)是一种脚本语言,功能强大。在浏览器中用JS脚本语言形成的书签(bookmarklet),可以完成很多意想不到的功能,比如用JS书签可以将值得分享的文章链接分享到各大社交网络中去。

大部分社交网络的分享功能都有相应的分享插件,甚至集成到智能手机浏览器中,但用JS书签的方法更简便,甚至可以实现本来没有的功能。iPhone, iPad中的Safari浏览器虽然内置分享到新浪微博、Twitter, Facebook的功能,但只能分享一个网址链接,并且没有集成Google+和腾讯微博,这时候,用JS书签就可以实现。

以下是几段社交分享JS代码,用鼠标左键按住相应名称拖拽到浏览器收藏栏(Safari, Chrome, Firefox, IE)即可,以后在需要分享相应网页的时候,点击相应书签,就可以方便地将网页分享给社交网络中的好友。

Google+

javascript:void(window.open('https://plus.google.com/share?ur\l='+encodeURIComponent(location), 'Share to Google+','width=600,height=460,menubar=no,location=no,status=no'));

Twitter

javascript:(function(){window.twttr=window.twttr||{};var D=550,A=450,C=screen.height,B=screen.width,H=Math.round((B/2)-(D/2)),G=0,F=document,E;if(C>A){G=Math.round((C/2)-(A/2))}window.twttr.shareWin=window.open('https://twitter.com/share','','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');E=F.createElement('script');E.src='https://platform.twitter.com/bookmarklets/share.js?v=1';F.getElementsByTagName('head')[0].appendChild(E)}());

Facebook

javascript:var d=document,f='https://www.facebook.com/share',l=d.location,e=encodeURIComponent,p='.php?src=bm&v=4&i=1378393915&u='+e(l.href)+'&t='+e(d.title);1;try{if (!/^(.*\.)?facebook\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z) {a=function() {if (!window.open(f+'r'+p,'sharer','toolbar=0,status=0,resizable=1,width=626,height=436'))l.href=f+p};if (/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0)

新浪微博

javascript:(function(){window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'&source=bookmark','_blank','width=450,height=400');})()

腾讯微博

javascript:(function(){outText='';for(i=0;i<document.images.length;i++){if(outText.indexOf(document.images[i].src)==-1){if(i==0){outText+=document.images[i].src;}else{outText+='|'+document.images[i].src}}};window.open('http://v.t.qq.com/share/share.php?title='+encodeURIComponent (document.title)+'&url='+encodeURIComponent(location.href)+'&appkey='+encodeURI("8cfebbdbe60d4898887bbd17c22f9260")+'&pic='+encodeURI(outText),'_blank','width=608,height=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,location=yes,resizable=no,status=no');})()

“用浏览器书签分享网页到社交网络”上的12条回复

g+分享不能编辑内容,比如要把图片去掉,找不到叉叉按钮

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注