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

以下是网页代码

QQ空间分享代码如下:

<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;" 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)" 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);" 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.rar (12.93 KB)

JS前端的分享功能的更多相关文章

  1. js 前端实现打印功能

      // 此处是一个打印的方法  可以在点击事件的时候调用 dayin = () =>{ // 获取当前页面要打印的内容  // 这里的className(‘print’)是我给要打印的区域起的 ...

  2. 1. web前端开发分享-css,js入门篇

    关注前端这么多年,没有大的成就,就入门期间积累了不少技巧与心得,跟大家分享一下,不一定都适合每个人,毕竟人与人的教育背景与成长环境心理活动都有差别,但就别人的心得再结合自己的特点,然后探索适合自己的学 ...

  3. web前端开发分享-css,js入门篇(转)

    转自:http://www.cnblogs.com/jikey/p/3600308.html 关注前端这么多年,没有大的成就,就入门期间积累了不少技巧与心得,跟大家分享一下,不一定都适合每个人,毕竟人 ...

  4. 微信JS分享功能--微信JS系列文章(二)

    概述 在上一篇文章微信JS初始化-- 微信JS系列文章(一)中已经介绍了微信JS初始化的相关工作,接下来本文继续就微信JS的分享功能进行描述,供大家参考. 代码 $(document).ready(f ...

  5. js分享功能

    引用JiaThis的分享功能: 直接在想要放置分享功能的地方加上如下代码即可: <!-- JiaThis Button BEGIN --> <div class="jiat ...

  6. js分享功能(微信,QQ,微博,空间,豆瓣等)

    日常编程中,我们可能会碰到项目中的分享功能,各大平台都有分享接口和文档说明,当然也有一些一键分享插件,例如:sosh,iShare.js等等 但有些同学不想引用插件,那么我整理了一些常用的分享至平台功 ...

  7. web前端开发分享-css,js入门篇

    学习没有捷径,但学习是有技巧与方法.   一,css入门篇:   推荐书籍:css哪些事儿,精通css. 理由:css那些事儿,他是一本介绍css基础类的书,是入门的经典读物. 系统的介绍了css的选 ...

  8. js 实现分享功能

    分享功能初步测试,title为当前页面的title. 其他详见注释!!! <!doctype html> <html> <head> <meta http-e ...

  9. php框架tp3.2.3和js写的微信分享功能心得,分享的标题内容图片自定义

    https://blog.csdn.net/weixin_42231483/article/details/81585322 最近用PHP的tp3.2.3框架和js写的微信分享功能心得,分享的标题内容 ...

随机推荐

  1. web beacon

    网络臭虫又叫 网络信标(Web beacon), 是可以暗藏在任何网页元素或邮件内的1像素大小的透明GIF或PNG图片 可以理解为<img src="http://www.webbea ...

  2. JavaScript 中实现继承的方式(列举3种在前一章,我们曾经讲解过创建类的最好方式是用构造函数定义属性,用原型定义方法。)

    第一种:对象冒充 function ClassA(sColor) { this.color = sColor; this.sayColor = function () { alert(this.col ...

  3. ural1987 Nested Segments

    Nested Segments Time limit: 1.0 secondMemory limit: 64 MB You are given n segments on a straight lin ...

  4. 在js中如何得到上传文件的大小。

    <html>  <head>  <script language="javascript">    function getSize() {   ...

  5. PAT (Advanced Level) 1009. Product of Polynomials (25)

    简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...

  6. JAV基础语法之---数据类型转换

    数制转换": 1.string 转 byte[] String str = "Hello";byte[] srtbyte = str.getBytes(); 2.byte ...

  7. iOS开发——NSArray中的字典排序

    手头上碰到一个项目,需要给数组中的字典中的一个字段排序,想了想,干脆再字典中增加一个字段,用来记录需要排序字段的第一个字符,用它来作为比较的对象,进行排序. - (void)viewDidLoad { ...

  8. Asp.net Ajax提供PageMethods调用

    页面上的Javascript通过ASP.NET AJAX除了可以调用Web服务类,还可以调用网页中的静态方法. <%@ Page Language="C#" %> &l ...

  9. (中等) HDU 5046 Airport ,DLX+可重复覆盖+二分。

    Description The country of jiuye composed by N cites. Each city can be viewed as a point in a two- d ...

  10. 远离DoS攻击 Windows Server 2016发布DNS政策

             Windows Server 2016的网络功能虽然没有获得像Docker容器和Nano Server同等重要的关注,但是管理员们应该了解的是,新的域名系统(Domain Name ...