自制簡易打賞功能的實(shí)例
1、申請開通cnblogs的JS代碼支持
2、將微信收款碼圖片上傳到cnblogs
3、將如下代碼中的http://files.cnblogs.com/files/eritpang/weixin.bmp替換為剛剛上傳的收款碼圖片的鏈接地址,然后將代碼添加到設(shè)置->博客側(cè)邊欄公告(支持HTML代碼)(支持JS代碼)里面,再點(diǎ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;" /> <title>打賞</title> <style type="text/css"> #dsSidebar { z-index: 999999; top: 18%; width: 200px; height: 200px; position: fixed; right: -200px; } #dsBtn { z-index: 999999; width: 30px; height: 58px; left: -30px; top: 80px; line-height: 28px; position: absolute; } .dsPanels { margin: 0px auto; overflow: hidden; } .dsPanel { float: left; margin: 0px 0px; padding: 12px 0px; text-align: center; background: #ffeedd; border-color: #ffeedd; border-radius: 8px; } .dsPanel-highlight { margin-top: 0; margin-bottom: 0; padding-left: 10px; padding-right: 10px; width: 160px; border: 8px solid #fd935c; } .dsPanel-button { display: block; font-size: 16px; font-weight: 500; color: #ffeedd; text-align: center; text-decoration: none; text-shadow: 0 1px rgba(black, .1); background: #fd935c; border-bottom: 2px solid #cf7e3b; border-color: rgba(black, .15); border-radius: 4px; } .dsPanel-title { width: 128px; margin: -15px auto 15px; padding-bottom: 0px; line-height: 22px; font-size: 14px; font-weight: bold; color: #ffeedd; text-shadow: 0 1px rgba(black, .05); background: #fd935c; border-radius: 0 0 4px 4px; } </style> <script> function moveBtn() { var dsBtn = document.getElementById("dsBtn"); var now = new Date(); var times = now.getTime(); var offsetSize = Math.sin(times / 380.0) * 15 + 45; var radius = Math.sin(times / 380.0) * 18 + 24; dsBtn.style.left = -offsetSize + 'px'; dsBtn.style.width = offsetSize + 'px'; dsBtn.style.borderRadius = radius + 'px'; setTimeout(moveBtn, 60); } var dsSidebarTimer = null; var dsSidebarOffsetRight = -200; function startMove(dsSidebarTarget, dsSidebarSpeed) { clearTimeout(dsSidebarTimer); function doMove() { var dsSidebar = document.getElementById('dsSidebar'); dsSidebarSpeed *= 0.9; if (dsSidebarSpeed > -1 && dsSidebarSpeed < 0) { dsSidebarSpeed = -1; } else if (dsSidebarSpeed < 1 && dsSidebarSpeed > 0) { dsSidebarSpeed = 1; } dsSidebarOffsetRight = dsSidebarOffsetRight + dsSidebarSpeed; if (dsSidebarSpeed > 0 && dsSidebarOffsetRight >= dsSidebarTarget) { dsSidebarOffsetRight = dsSidebarTarget; dsSidebar.style.right = dsSidebarOffsetRight + 'px'; } else if (dsSidebarSpeed < 0 && dsSidebarOffsetRight <= dsSidebarTarget) { dsSidebarOffsetRight = dsSidebarTarget; dsSidebar.style.right = dsSidebarOffsetRight + 'px'; } else { dsSidebar.style.right = dsSidebarOffsetRight + 'px'; dsSidebarTimer = setTimeout(doMove, 30); } } doMove(); } document.getElementById('dsImg').onload = function () { var dsSidebar = document.getElementById('dsSidebar'); dsSidebar.onmouseover = function () { startMove(0, 24); } dsSidebar.onmouseout = function () { startMove(-200, -24); } moveBtn(); } </script> </head> <body> <div id="dsSidebar"> <div class="dsPanels"> <div class="dsPanel dsPanel-highlight"> <p class="dsPanel-title">喜歡請用微信打賞</p> <img id='dsImg' src="http://files.cnblogs.com/files/eritpang/weixin.bmp" alt="" width="160" height="160" /> </div> </div> <span class="dsPanel-button" id='dsBtn'><b>打<br/>賞</b></span> </div> </body> </html>
4、效果如下。
以上這篇自制簡易打賞功能的實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript判斷手機(jī)號運(yùn)營商是移動、聯(lián)通、電信還是其他(代碼簡單)
本文由腳本之家小編給大家分享的基于js判斷手機(jī)號運(yùn)行商是移動、聯(lián)通、電信還是其他的,然后根據(jù)不同的運(yùn)營商做出對應(yīng)的處理,感興趣的朋友一起學(xué)習(xí)吧2015-09-09JavaScript使用簡單正則表達(dá)式的數(shù)據(jù)驗(yàn)證功能示例
這篇文章主要介紹了JavaScript使用簡單正則表達(dá)式的數(shù)據(jù)驗(yàn)證功能,結(jié)合實(shí)例形式分析了JS針對表單輸入內(nèi)容的簡單正則驗(yàn)證操作技巧,需要的朋友可以參考下2017-01-01js實(shí)現(xiàn)時間顯示幾天前、幾小時前或者幾分鐘前的方法集錦
這篇文章主要介紹了js實(shí)現(xiàn)時間顯示幾天前、幾小時前或者幾分鐘前的方法,實(shí)例匯總分析了時間顯示格式轉(zhuǎn)換的常用思路與技巧,需要的朋友可以參考下2015-05-05Typescript 實(shí)現(xiàn)函數(shù)重載的方式
函數(shù)重載簡單點(diǎn)說就是,同一個函數(shù)的不同實(shí)現(xiàn)方式,根據(jù)傳入的參數(shù)的類型或者長度,決定最終調(diào)用哪一個實(shí)現(xiàn),本文給大家介紹了Typescript 實(shí)現(xiàn)函數(shù)重載的方式,需要的朋友可以參考下2024-05-05js實(shí)現(xiàn)根據(jù)身份證號自動生成出生日期
這篇文章主要介紹了js實(shí)現(xiàn)根據(jù)身份證號自動生成出生日期,需要的朋友可以參考下2015-12-12ArrayBuffer Uint8Array Blob與文本字符相互轉(zhuǎn)換示例
這篇文章主要為大家介紹了ArrayBuffer Uint8Array Blob與文本字符相互轉(zhuǎn)換示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06javascript正則表達(dá)式中參數(shù)g(全局)的作用
表達(dá)式加上參數(shù)g之后,表明可以進(jìn)行全局匹配,注意這里可以的含義。2010-11-11