javascript實(shí)現(xiàn)類似百度分享功能的方法
本文實(shí)例講述了javascript實(shí)現(xiàn)類似百度分享功能的方法。分享給大家供大家參考。具體如下:
像騰訊,開心社區(qū)都提供這種分享接口的,做百度分享功能很簡(jiǎn)單的
一般網(wǎng)站要接入分享功能,大部分都用百度分享和addthis的代碼,可是自己定制性太差,該分享功能樣式都可以自己修改,簡(jiǎn)潔沒過多js代碼,大大提高網(wǎng)頁(yè)加載速度。
運(yùn)行效果如下圖所示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>網(wǎng)絡(luò)分享代碼分享</title> <style type="text/css"> /** * 分享代碼樣式 * by kily */ #ak_share { padding:10px 0; font-size:12px; } .ak_share { height:1%; overflow:hidden; } .ak_share dt { float:left; font-weight:bold; color:#A5A5A5; height:16px; line-height:16px; } .ak_share dd { margin-right:10px; margin-left:0; height:16px; float:left; } .ak_share a:hover { color:#ed7811; text-decoration:underline;} .ak_share a { float:left; height:16px; line-height:16px; padding-left:18px; background:url(http://www.yem120.com/images/share.gif) left top no-repeat; color:#666; text-decoration:none; } .ak_share .t_163_s { background-position: 0 -16px; } .ak_share .t_qq_s { background-position: 0 -32px; } .ak_share .qzone_s { background-position: 0 -48px; } .ak_share .douban_s { background-position: 0 -64px; } </style> </head> <body> <div id="ak_share"> <dl class="ak_share"> <dt>分享:</dt> <dd> <a class="t_sina_s" href="javascript:(function(){window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'&source=bookmark','_blank','width=450,height=400');})()" title="分享到新浪微博" rel="nofollow">新浪微博</a> </dd> <dd> <a class="t_163_s" href="javascript:(function(){window.open('http://t.163.com/article/user /checkLogin.do?link=http://news.163.com/&source=' + '&info='+encodeURIComponent(document.title)+' '+encodeURIComponent(location.href),'_blank','width=510,height=300');})()" title="分享到網(wǎng)易微博" rel="nofollow">網(wǎng)易微博</a> </dd> <dd> <a class="t_qq_s" href="javascript:(function(){window.open('http://v.t.qq.com/share/share.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'&source=bookmark','_blank','width=610,height=350');})()" title="分享到騰訊微博" rel="nofollow">騰訊微博</a> </dd> <dd> <a class="qzone_s" href="javascript:void(window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(document.location.href)));" title="分享到QQ空間" rel="nofollow">QQ空間</a> </dd> <dd> <a class="douban_s" href="javascript:void(function(){var%20d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:' ',r='http://www.douban.com/recommend/?url='+e(d.location.href)+'&title='+e(d.title)+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()" title="推薦到豆瓣" rel="nofollow">豆瓣</a> </dd> </dl> </div> </body> </html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
相關(guān)文章
JavaScript模塊管理的簡(jiǎn)單實(shí)現(xiàn)方式詳解
這篇文章主要介紹了JavaScript模塊管理的簡(jiǎn)單實(shí)現(xiàn)方式,它方便組織你的代碼,提高項(xiàng)目的可維護(hù)性。一個(gè)項(xiàng)目的可維護(hù)性高不高,也體現(xiàn)一個(gè)程序員的水平,在如今越來越復(fù)雜的前端項(xiàng)目,這一點(diǎn)尤為重要。,需要的朋友可以參考下2019-06-06bootstrap Table實(shí)現(xiàn)合并相同行
這篇文章主要為大家詳細(xì)介紹了bootstrapTable實(shí)現(xiàn)合并相同行,fastadmin框架同樣使用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-07-07js判斷ie版本號(hào)的簡(jiǎn)單實(shí)現(xiàn)代碼
本篇文章主要是對(duì)js判斷ie版本號(hào)的簡(jiǎn)單實(shí)現(xiàn)代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-03-03Json實(shí)現(xiàn)傳值到后臺(tái)代碼實(shí)例
這篇文章主要介紹了Json實(shí)現(xiàn)傳值到后臺(tái)代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06詳解用函數(shù)式編程對(duì)JavaScript進(jìn)行斷舍離
本篇文章主要介紹了用函數(shù)式編程對(duì)JavaScript進(jìn)行斷舍離,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09JS實(shí)現(xiàn)超精簡(jiǎn)的鏈接列表在固定區(qū)域內(nèi)滾動(dòng)效果代碼
這篇文章主要介紹了JS實(shí)現(xiàn)超精簡(jiǎn)的鏈接列表在固定區(qū)域內(nèi)滾動(dòng)效果代碼,非常常見的頁(yè)面元素屬性變換控制實(shí)現(xiàn)滾動(dòng)效果,簡(jiǎn)單實(shí)用,需要的朋友可以參考下2015-11-11js實(shí)現(xiàn)黑色簡(jiǎn)易的滑動(dòng)門網(wǎng)頁(yè)tab選項(xiàng)卡效果
這篇文章主要介紹了js實(shí)現(xiàn)黑色簡(jiǎn)易的滑動(dòng)門網(wǎng)頁(yè)tab選項(xiàng)卡效果,可實(shí)現(xiàn)簡(jiǎn)單的鼠標(biāo)滑過tab項(xiàng)切換對(duì)應(yīng)菜單的功能,涉及javascript鼠標(biāo)事件控制頁(yè)面元素的遍歷與樣式改變實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08