首页 技术 正文
技术 2022年11月14日
0 收藏 494 点赞 3,502 浏览 3662 个字

给网页加上分享代码,借助网友的力量推广网站,目前已经很流行了

以下是网页代码

QQ空间分享代码如下:

<a href="javascript:void(0);" rel="external nofollow"  rel="external nofollow"  onclick="window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(document.location.href));return false;" title="分享到QQ空间"><img src="http://qzonestyle.gtimg.cn/ac/qzone_v5/app/app_share/qz_logo.png" alt="分享到QQ空间" /></a>

新浪微博分享代码如下:

<script type="text/javascript">document.write('<iframe frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?url=%url%&appkey=&type=3" width="16" height="16"></iframe>'.replace(/%url%/,encodeURIComponent(location.href)));</script>

腾讯微博分享代码如下:

<a href="javascript:void(0)" rel="external nofollow"  onclick="postToWb();" class="tmblog"><img src="http://v.t.qq.com/share/images/s/weiboicon16.png"></a> <script type="text/javascript">

function postToWb(){

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 = '';//你的网站地址

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' );

}

</script>

QQ朋友社区分享代码如下:

<a href="javascript:void(0);" rel="external nofollow"  rel="external nofollow"  onclick="window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?to=pengyou&url='+encodeURIComponent(document.location.href));return false;" title="分享到朋友社区"><img src="http://qzonestyle.gtimg.cn/ac/qzone_v5/app/qzshare/xy-icon.png" alt="分享到朋友社区" /></a>

这里发个自己DIY的分享代码,喜欢的可以拿去用,预览图如下

图片素材在压缩包里,代码内容如下,保存为js文件即可,压缩包里也有现成的。

document.writeln("<a href=\"javascript:void((function(s,d,e){try{}catch(e){}var f=\'http:\/\/v.t.sina.com.cn\/share\/share.php?\',u=d.location.href,p=[\'url=\',e(u),\'&title=\',e(d.title),\'&appkey=2924220432\'].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()}})(screen,document,encodeURIComponent));\"><img src=\"sina.gif\" \/><\/a>");

document.writeln("<a href=\"javascript:void(0);\" onclick=\"window.open(\'http:\/\/sns.qzone.qq.com\/cgi-bin\/qzshare\/cgi_qzshare_onekey?url=\'+encodeURIComponent(document.location.href));return false;\"><img src=\"qzone.gif\" \/><\/a>");

document.writeln("<a href=\"javascript:void(0)\" onclick=\"postToWb();\"><img src=\"sq.gif\" \/><\/a>");

document.writeln("<script type=\"text\/javascript\">function postToWb(){");

document.writeln("var _t = encodeURI(document.title);");

document.writeln("var _url = encodeURI(document.location);");

document.writeln("var _appkey = encodeURI(\"appkey\");\/\/你从腾讯获得的appkey");

document.writeln("var _pic = encodeURI(\'\');\/\/(列如:var _pic=\'图片url1|图片url2|图片url3....)");

document.writeln("var _site = \'\';\/\/你的网站地址");

document.writeln("var _u = \'http:\/\/v.t.qq.com\/share\/share.php?title=\'+_t+\'&url=\'+_url+\'&appkey=\'+_appkey+\'&site=\'+_site+\'&pic=\'+_pic;");

document.writeln("window.open( _u,\'转播到腾讯微博\', \'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no\' );}<\/script>");

document.writeln("<a href=\"javascript:window.open(\'http:\/\/cang.baidu.com\/do\/add?it=\'+encodeURIComponent(document.title.substring(0,76))+\'&iu=\'+encodeURIComponent(location.href)+\'&fr=ien#nw=1\',\'_blank\',\'scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes\'); void 0\"><img src=\"baidu.gif\" \/><\/a>");

JS前端的分享功能

下载地址:JS前端的分享功能微博分享js.rar (12.93 KB)

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,493
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,133
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,297