js 实现分享功能_weixin_30800807的博客-程序员宅基地

技术标签: php  

分享功能初步测试,title为当前页面的title。 其他详见注释!!!

<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" Content="text/html; charset=utf-8;">
    <title>分享代码测试</title>
    <meta name="author" content="rainna" />
    <meta name="keywords" content="rainna's js lib" />
    <meta name="description" content="js" />
    <style>
        *{
     margin:0;padding:0;}
        img{
     border:0 none;}
        body{
     background:#eee;}
        .m-box{
     width:800px;margin:0 auto;padding:20px;background:#fff;}
        .m-box p{
     margin:0 0 10px;}
        .m-box .icn a{
     display:block;width:55px;height:35px;background:url('http://l.bst.126.net/rsc/img/weibo.png?035') no-repeat;}
        .m-box .icn .wb1{
     background-position:10px -216px;}
        .m-box .icn .wb2{
     background-position:-190px -216px;}
        .m-box .icn .wb3{
     background:url(http://l.bst.126.net/rsc/img/postshare/tieba24.png) 15px 0 no-repeat;}
        .m-box .icn .wb4{
     background-position:-88px -215px;}
        .m-box .icn .wb5{
     background-position:-138px -216px;}
        .m-box .icn .wb6{
     background-position:-245px -216px;}
        .m-box .icn .wb7{
     background-position:-300px -216px;}
        .m-box .icn .wb8{
     background-position:-355px -216px;}
        .m-box .icn .wb9{
     background-position:-415px -215px;}
    </style>
</head>
<body>
    <div class="m-box">
        <p>分享到微信,易信:</p>
        <div class="icn"><img width="200" src="https://qr.api.cli.im/qr?data=http%253A%252F%252Fwww.cnblogs.com%252FCooLLYP%252F&level=H&transparent=false&bgcolor=%23ffffff&forecolor=%23000000&blockpixel=12&marginblock=1&logourl=&size=280&kid=cliim&key=6b3febe84f9780fb193f9d8f9d189e4f" /></div>
    </div>
    <div class="m-box">
        <p>分享到新浪微博:<a href="http://open.weibo.com/wiki/ShareCode" target="_blank">http://open.weibo.com/wiki/ShareCode</a></p>
        <div class="icn"><a href="#" class="wb1" onclick="shareToSinaWB(event)"></a></div>
    </div>
    <div class="m-box">
        <p>分享到QQ空间:<a href="http://connect.qq.com/intro/share/" target="_blank">http://connect.qq.com/intro/share/</a></p>
        <div class="icn"><a href="#" class="wb2" onclick="shareToQzone(event)"></a></div>
    </div>
    <div class="m-box">
        <p>分享到百度贴吧:<a href="http://share.baidu.com/code/advance" target="_blank">http://share.baidu.com/code/advance</a></p>
        <div class="icn"><a href="#" class="wb3" onclick="shareToTieba(event)"></a></div>
    </div>
    <div class="m-box">
        <p>分享到豆瓣:</p>
        <div class="icn"><a href="#" class="wb4" onclick="shareToDouban(event)"></a></div>
    </div>
    <div class="m-box">
        <p>分享到腾迅微博:<a href="http://dev.t.qq.com/websites/share/" target="_blank">http://dev.t.qq.com/websites/share/</a></p>
        <div class="icn"><a href="#" class="wb5"  onclick="shareToQQwb(event)"></a></div>
    </div>
    <div class="m-box">
        <p>分享到开心网:<a href="http://open.kaixin001.com/document.php?type=records#code" target="_blank">http://open.kaixin001.com/document.php?type=records#code</a></p>
        <div class="icn"><a href="#" class="wb7" onclick="shareToKaixin(event)"></a></div>
    </div>
    <div class="m-box">
        <p>分享到facebook:</p>
        <div class="icn"><a href="#" class="wb8" onclick="shareToFacebook(event)"></a></div>
    </div>
    <div class="m-box">
        <p>分享到Twitter:</p>
        <div class="icn"><a href="#" class="wb9" onclick="shareToTwitter(event)"></a></div>
    </div>
    <script>
        var _title,_source,_sourceUrl,_pic,_showcount,_desc,_summary,_site,
            _width = 600,
            _height = 600,
            _top = (screen.height-_height)/2,
            _left = (screen.width-_width)/2,
            _url = 'http://www.cnblogs.com/CooLLYP/',
            _pic = 'https://pic.cnblogs.com/avatar/1035330/20160929170744.png';
        //分享到新浪微博
        function shareToSinaWB(event){
            event.preventDefault();
            var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136';     //真实的appkey,必选参数    
            _shareUrl += '&url='+ encodeURIComponent(_url||document.location);     //参数url设置分享的内容链接|默认当前页location,可选参数 
            _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享的标题|默认当前页标题,可选参数
            _shareUrl += '&source=' + encodeURIComponent(_source||'');
            _shareUrl += '&sourceUrl=' + encodeURIComponent(_sourceUrl||'');
            _shareUrl += '&content=' + 'utf-8';   //参数content设置页面编码gb2312|utf-8,可选参数
            _shareUrl += '&pic=' + encodeURIComponent(_pic||'');  //参数pic设置图片链接|默认为空,可选参数
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no, resizable=1,location=no,status=0');
        }
        //分享到QQ空间
        function shareToQzone(event){
            event.preventDefault();
            var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?';
            _shareUrl += 'url=' + encodeURIComponent(_url||document.location);   //参数url设置分享的内容链接|默认当前页location
            _shareUrl += '&showcount=' + _showcount||0;      //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示
            _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述');    //参数desc设置分享的描述,可选参数
            _shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要');    //参数summary设置分享摘要,可选参数
            _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享标题,可选参数
            _shareUrl += '&site=' + encodeURIComponent(_site||'');   //参数site设置分享来源,可选参数
            _shareUrl += '&pics=' + encodeURIComponent(_pic||'');   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
        //分享到百度贴吧
        function shareToTieba(event){
            event.preventDefault();
            var _shareUrl = 'http://tieba.baidu.com/f/commit/share/openShareApi?';
            _shareUrl += 'title=' + encodeURIComponent(_title||document.title);  //分享的标题
            _shareUrl += '&url=' + encodeURIComponent(_url||document.location);  //分享的链接
            _shareUrl += '&pic=' + encodeURIComponent(_pic||'');    //分享的图片
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
        //分享到豆瓣
        function shareToDouban(event){
            event.preventDefault();
            var _shareUrl = 'http://shuo.douban.com/!service/share?';
            _shareUrl += 'href=' + encodeURIComponent(_url||location.href);    //分享的链接
            _shareUrl += '&name=' + encodeURIComponent(_title||document.title);    //分享的标题
            _shareUrl += '&image=' + encodeURIComponent(_pic||'');    //分享的图片
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
        //分享到腾迅微博
        function shareToQQwb(event){
            event.preventDefault();
            var _shareUrl = 'http://v.t.qq.com/share/share.php?';
            _shareUrl += 'title=' + encodeURIComponent(_title||document.title);    //分享的标题
            _shareUrl += '&url=' + encodeURIComponent(_url||location.href);    //分享的链接
            _shareUrl += '&appkey=5bd32d6f1dff4725ba40338b233ff155';    //在腾迅微博平台创建应用获取微博AppKey
            _shareUrl += '&site=' + encodeURIComponent(_site||'');   //分享来源
            _shareUrl += '&pic=' + encodeURIComponent(_pic||'');    //分享的图片,如果是多张图片,则定义var _pic='图片url1|图片url2|图片url3....'
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
        //分享到开心网
        function shareToKaixin(event){
            event.preventDefault();
            var _shareUrl = 'http://www.kaixin001.com/rest/records.php?';
            _shareUrl += 'url=' + encodeURIComponent(_url||location.href);    //分享的链接
            _shareUrl += '&content=' + encodeURIComponent('分享的文字');    //需要分享的文字,当文字为空时,自动抓取分享网址的title
            _shareUrl += '&pic=' + encodeURIComponent(_pic||'');     //分享的图片,多个使用半角逗号分隔
            _shareUrl += '&showcount=0';    //是否显示分享数,显示:'1',不显示:'0'
            _shareUrl += '&style=11';      //显示的样式,必选参数
            _shareUrl += '&aid=' + encodeURIComponent(_site||'');    //显示分享来源
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
        function shareToKaixin2(event){
            event.preventDefault();
            var _shareUrl = 'http://www.kaixin001.com/repaste/share.php?';
            _shareUrl += 'rtitle=' + encodeURIComponent(_title||document.title);   //分享的标题
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
        //分享到facebook
        function shareToFacebook(event){
            event.preventDefault();
            var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?';
            _shareUrl += 'u=' + encodeURIComponent(_url||location.href);    //分享的链接
            _shareUrl += '&t=' + encodeURIComponent(_title||document.title);    //分享的标题
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
        //分享到Twitter
        function shareToTwitter(event){
            event.preventDefault();
            var _shareUrl = 'http://twitter.com/intent/tweet?';
            _shareUrl += 'url=' + encodeURIComponent(_url||location.href);    //分享的链接
            _shareUrl += '&text=' + encodeURIComponent(_title||document.title);    //分享的标题
            window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
        }
    </script>
</body>
</html>

 

转载于:https://www.cnblogs.com/CooLLYP/p/7527719.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30800807/article/details/97537126

智能推荐

使用scroll-view小程序滑动过程不断动态加载节点 实现丝滑滑动效果_uniapp 使用scroll-view小程序滑动过程不断动态加载节点 实现丝滑滑动效果_koeika科科的博客-程序员宅基地

使用scroll-view当位置变动时 记录scrollLeft同时 scroll-view 加scroll-anchoring属性防止在滑动过程中位置改变导致scrollLeft不固定 产生抖动

logback只打印当前级别的日志_Sunstack的博客-程序员宅基地

springboot默认使用了logback作为日志框架,如果你引入了springbootstart-web模块,那么就不需要额外引入logback的依赖logback只打印当前级别日志 主要是由于对于appender组件的不熟悉 &amp;lt;appender name=&quot;CONSOLE&quot; class=&quot;ch.qos.logback.core.ConsoleAppender&quot;&amp;g...

SpringBoot - 02 - 自定义LogBack、加载properties中自定义变量_logback spring 自定义变量_Simba_cheng的博客-程序员宅基地

接着昨天的项目继续。项目GitHub:SpringBoot-SpringCloud GitHub地址主类没有变动,这里就不贴了。package com.server.vo;import org.springframework.boot.context.properties.ConfigurationProperties;import org.springframework.context.a...

软件工程导论——详解白盒测试和黑盒测试中的各种方法_jhw_12138的博客-程序员宅基地

/资料参考软件工程导论《第六版》张海藩著//资料参考来源https://www.jianshu.com/p/3152765ec902//资料参考来源https://blog.csdn.net/LOVEYSUXIN/article/details/82592588//资料参考来源https://www.cnblogs.com/dayu2019/p/11555447.html/1.白盒测试覆...

SpringMVC之http请求头和响应头(四)_yll1024335892的博客-程序员宅基地

Request Headers   Accept:接收什么样的资源Accept-Encoding:编码格式Accept-Language:语言格式Cache-Control:缓存控制Connection:连接是否长连接Cookie: cookie值Host:主机If-Modified-Sin

随便推点

python解决因路径问题导致的三方库不可用问题_python解释器加载不出来插件_SailorMoon_sweet的博客-程序员宅基地

转载:利用PyCharm中的终端安装第三方库但无法成功导入project的问题 - 程序员大本营 (pianshen.com)看了好多,这个最简单明了,先马住如果已经确定安装成功了,可以在终端试一下,我的情况是在终端import成功,但是在我的python编辑器里面却失败,原因是他找不到该模块。这说明在这个project中没有成功导入刚刚安装的pydicom模块,究其原因,是当前project的虚拟环境(virtual environment)没有导入该模块,所以我才用的解决办法是重新创建一个新

基于matlab的三维柱状图绘制_matlab三维柱状图_deep_learninger的博客-程序员宅基地

基于matlab的三维柱状图绘制摘要: 对于生物建模、数据统计等,经常会得到三维数据,绘制三维柱状图是显示它们的重要方式。但matlab绘制三维柱状图,可能需要进一步的人工干预才能得到预想的效果。这里简要介绍一下基于matlab的三维柱状图绘制。 ...简介对于生物建模、数据统计等,经常会得到三维数据,绘制三维柱状图是显示它们的重

蓝宝石rx580怎么超频_电脑硬件评测 篇四十五:杀鸡焉用牛刀?风冷能压绝不用水冷,超频三东海X7 CPU散热器助阵i5 9600KF_散热风扇..._崔庆才丨静觅的博客-程序员宅基地

2020-12-24 22:41:36303点赞10收藏10评论你是AMD Yes党?还是intel和NVIDIA的忠实簇拥呢?最新一届#装机大师赛#开始啦!本次装机阵营赛分为3A红组、intel NVIDIA蓝绿组、混搭组还有ITX组,实体or虚拟装机都能参与,可使用值得买定制化DIY装机工具在文中展现配置单!每个小组均有精美礼品,优秀文章还可角逐装机大师终极大奖,点击参与&lt;&lt;&lt...

Spark面试汇总_BigMoM1573的博客-程序员宅基地

文章目录1、Spark有几种部署方式?(重点)2、Spark提交作业参数(重点)3、简述Spark on yarn的作业提交流程(重点)4、请列举Spark的transformation算子(不少于5个)(重点)5、请列举Spark的action算子(不少于5个)(重点)6、简述Spark的两种核心Shuffle(重点)7、简述SparkSQL中RDD、DataFrame、DataSet三者的区别与联系?(重点)8、Repartition和Coalesce关系与区别(重点)9、Spark中cache默认缓存

python因子分析_python中的因子分析简介_weixin_26750481的博客-程序员宅基地

python因子分析Factor Analysis (FA) is an exploratory data analysis method used to search influential underlying factors or latent variables from a set of observed variables. It helps in data interpretatio...

python.freelycode.com-快速提示-使用Modin加速Pandas_weixin_37988176的博客-程序员宅基地

Python部落(python.freelycode.com)组织翻译,禁止转载,欢迎转发。我最近偶然发现了一个叫做Modin[1]的小型库,它声称可以让pandas运行的更快。他们用来描述这个项目的其中一句话是:&quot;通过更改一行代码来加速你的pandas工作流&quot;听起来很有趣,如果是真的话,那就意义重大了。使用modin只需要导入modin来代替pandas,并且也不需要更改你的...

推荐文章

热门文章

相关标签