标签:
增加页面访问量是提高的前提下,站点信息的影响。增加页面访问量是不同的,它被添加到一个特定的页面在页面上是一个非常好的主意分享,网页共享的实现非常多,这里解释一下百度分享应用:
一、百度分享相关网址:
获代替码:http://share.baidu.com/code
帮助文档:http://share.baidu.com/help
二、百度分享之图标式:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>图标式</title> </head> <body> <!-- Baidu Button BEGIN --> <div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare"> <a class="bds_qzone"></a> <a class="bds_tsina"></a> <a class="bds_tqq"></a> <a class="bds_renren"></a> <span class="bds_more">很多其他</span> </div> <script type="text/javascript" id="bdshare_js" data="type=tools&mini=1" ></script> <script type="text/javascript" id="bdshell_js"></script> <script type="text/javascript"> var bds_config = { ‘bdText‘:‘分享内容‘, ‘bdComment‘:‘分享评论‘, ‘bdPic‘:‘http://avatar.csdn.net/E/A/D/1_wangshuxuncom.jpg‘ }; document.getElementById(‘bdshell_js‘).src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000); </script> <!-- Baidu Button END --> </body> </html>
三、百度分享之文字式:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"; String skinId = request.getParameter("skinId"); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>文字式</title> <style type="text/css"> a{ text-decoration: none; } </style> </head> <body> <div class="bdsharebuttonbox"> <a href="#" class="bds_more" data-cmd="more">分享到:</a> <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间">QQ空间</a> <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博">新浪微博</a> <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博">腾讯微博</a> <a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网">人人网</a> <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信">微信</a> </div> <script type="text/javascript"> window._bd_share_config={ "common":{"bdText":"分享内容","bdComment":"分享评论","bdMini":"2","bdMiniList":false,"bdPic":"http://avatar.csdn.net/E/A/D/1_wangshuxuncom.jpg","bdStyle":"0","bdSize":"16"}, "share":{"bdSize":16}, "image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"}, "selectShare":{"bdContainerClass":"bdsharebuttonbox","bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]} }; with(document)0[(getElementsByTagName(‘head‘)[0]||body).appendChild(createElement(‘script‘)).src=‘http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=‘+~(-new Date()/36e5)]; </script> </body> </html>
三、百度分享之浮窗式
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"; %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>浮窗式</title> <script type="text/javascript"> window._bd_share_config={ "common":{"bdText":"分享内容","bdComment":"分享评论","bdMini":"2","bdMiniList":false,"bdPic":"http://avatar.csdn.net/E/A/D/1_wangshuxuncom.jpg","bdStyle":"0","bdSize":"16"}, "slide":{"type":"slide","bdImg":"6","bdPos":"right","bdTop":"250"}, "image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"}, "selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]} }; with(document)0[(getElementsByTagName(‘head‘)[0]||body).appendChild(createElement(‘script‘)).src=‘http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=‘+~(-new Date()/36e5)]; </script> </head> <body> </body> </html>
五、遇到的问题及其解决方法:
①、我的project名为shareDemo,项目通过Tomcat公布,http输入http://localhost:8080/share/index.html,然后选择并点击“分享到QQ空间”,但是出来的界面不能显示分享内容(例如以下图),但是其他分享好用:
图片4-1-1
解决方法:这样的问题并非你的代码写错了。而是QQ做了限制——假设http请求中为localhost,那么是不会返回结果的。能够通过将localhost改为计算机IP地址或者改为127.0.0.1解决问题。
②、使用浮窗式百度分享时,用IE打开对应的页面,没有发现所谓的“浮窗”啊,其他浏览器(譬如火狐、谷歌或者Safari)都好用?
解决方法:嗯嗯嗯,这个问题我也以前遇到过,几经研究发现是页面文档类型搞的鬼——研究发现假设为“<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">”,则在IE或者360浏览器中浮窗式的百度分享会不好用——显示不出来;假设为“<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">”则在IE或者360浏览器中浮窗式的百度分享会比較好的显示出来。
补充性说明:上面列出的三个样例是最简单的样例,要弄清每一个參数什么意思以及其他的一些配置。请訪问官方站点。
【0分下载资源】
版权声明:本文博主原创文章。博客,未经同意不得转载。
标签:
原文地址:http://www.cnblogs.com/lcchuguo/p/4838544.html