JS实现常用的分享到按钮
2024-08-28 02:42:14
我们阅读博客的时候经常会用到这样功能,当然有时候也会想把自己的网站上也加入类似的分享功能,各大厂商已经给出了相应的API,点击一个按钮即可弹出窗口进入分享,我们事先可以设置一些参数,一般常用的就是 网站的网址,图片还有一些内容描述。这里我写了三个方法,分别分享到 新浪微博,Q空间,以及腾讯微博
~~~ 应该 encodeURIComponent()一下比较好
<!DOCTYPE html>
<html>
<head></head>
<body> <script> var ShareTip = function()
{ }
//分享到腾讯微博
ShareTip.prototype.sharetoqq=function(content,url,picurl)
{
var shareqqstring='http://v.t.qq.com/share/share.php? title='+content+'&url='+url+'&pic='+picurl;
window.open(shareqqstring,'newwindow','height=100,width=100,top=100,left=100');
}
//分享到新浪微博
ShareTip.prototype.sharetosina=function(title,url,picurl)
{
var sharesinastring='http://v.t.sina.com.cn/share/share.php? title='+title+'&url='+url+'&content=utf-8&sourceUrl='+url+'&pic='+picurl;
window.open(sharesinastring,'newwindow','height=400,width=400,top=100,left=100');
}
//分享到QQ空间
ShareTip.prototype.sharetoqqzone=function(title,url,picurl)
{
var shareqqzonestring='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey? summary='+title+'&url='+url+'&pics='+picurl;
window.open(shareqqzonestring,'newwindow','height=400,width=400,top=100,left=100');
} var share1=new ShareTip();
share1.sharetoqqzone("这是一本关于地图故事的集锦,以一本书的形式来展示地图故事,我们可 以使用鼠标拖动来翻页,或者点击翻页按钮,点击 马上体验,可以体验故事,同时在触屏上也有很好 的体验效果奥,地图故事,尽在书中,赶快体验吧,建议使用对 HTML5支持较好的浏览 器","http://tm.arcgisonline.cn:8038/App101/MapstoryBook/Default.html","http://tm.arcgisonl ine.cn:8038/App101/MapstoryBook/css/Img/ShareBook.jpg"); </script>
</body>
</html>
以上的函数分别具有三个参数,内容,网址,以及 图片,也就是我们想要分享的内容
最新文章
- 基本动画CABasicAnimation - 完成之后闪回初始状态
- 加载状态为complete时移除loading效果
- 未能找到元数据文件“引用的DLL的路径”
- centos7 php7 安装composer时Failed to decode zlib stream解决办法
- Pie Charts
- FileAttributes枚举
- JS中this到底指向谁?
- linux设置代理修改接口数据
- JAVA之旅(三十二)——JAVA网络请求,IP地址,TCP/UDP通讯协议概述,Socket,UDP传输,多线程UDP聊天应用
- docker daemon 配置文件
- ubuntu 16.04上 mysql 5.7 安装笔记
- 1.1.27 word表格里的文字不显示
- effective java——12考虑实现coparable接口
- Clover 3 --- Windows Explorer 资源管理器的一个扩展,为其增加类似谷歌 Chrome 浏览器的多标签页功能。
- Linux之Vim学习
- Android开发——高斯模糊效果的简单实现
- JS如何获取url查询字符串的键和值?
- List集合添加自定义对象
- Python全栈day 01
- shell sort 排序大讨论
热门文章
- josscrowcroft / Simple-JavaScript-DOM-Inspector
- poj 1459 (最大流)
- Android MediaPlayer Error -1004
- Android中各种Adapter的使用方法
- ZOJ 38727(贪心)
- How draw a stem -and -leaf &;amp; box-plot display by R.or Python
- git 使用笔记(三)-分支的使用
- vs2013出现ISO C++ conformant解决办法
- Spring学习之Aop的各种增强方法
- ORA-12514(TNS:监听程序当前无法识别...)