网站折腾 之 javascript

  Default  211℃  0条  382字数  预计阅读时间1分钟

timg.jpg
以下代码均不知原作者
来源网络 整理修改
实在太长了 可以通过右侧目录书查看
下载地址在文中

第一款 给网站添加点击特效 心

<script type="text/javascript">
    !function (e, t, a) {
    function r() {
    for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
    requestAnimationFrame(r)
    }
    function n() {
    var t = "function" == typeof e.onclick && e.onclick;
    e.onclick = function (e) {
    t && t(), o(e)
    }
    }
    function o(e) {
    var a = t.createElement("div");
    a.className = "heart", s.push({
    el: a,
    x: e.clientX - 5,
    y: e.clientY - 5,
    scale: 1,
    alpha: 1,
    color: c()
    }), t.body.appendChild(a)
    }
    function i(e) {
    var a = t.createElement("style");
    a.type = "text/css";
    try {
    a.appendChild(t.createTextNode(e))
    } catch (t) {
    a.styleSheet.cssText = e
    }
    t.getElementsByTagName("head")[0].appendChild(a)
    }
    function c() {
    return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
    }
    var s = [];
    e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
    setTimeout(e, 1e3 / 60)
    }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
    }(window, document);
    </script>

第二款 网站焦点监控

<script>
var OriginTitile = document.title,
titleTime;
document.addEventListener("visibilitychange",
function() {
    if (document.hidden) {
        $;
        document.title = "哼 讨厌 你怎么走了吖 o_O!";
        clearTimeout(titleTime)
    } else {
        $;
        document.title = "呀呀呀 回来了!" + OriginTitile;
        titleTime = setTimeout(function() {
            document.title = OriginTitile
        },
        2000)
    }
});
</script>

另外一种

<script>
    var originalTitle = document.title;
    window.onblur = function(){document.title = '要玩捉迷藏吗'};
    window.onfocus = function(){document.title = originalTitle};
</script>

第三款 闪烁字体

在适当位置添加 <p id="binft"></p>
引入 JavaScript

<script>
var binft = function (r) {
    function t() {
        return b[Math.floor(Math.random() * b.length)]
    }

    function e() {
        return String.fromCharCode(94 * Math.random() + 33)
    }

    function n(r) {
        for (var n = document.createDocumentFragment(), i = 0; r > i; i++) {
            var l = document.createElement("span");
            l.textContent = e(), l.style.color = t(), n.appendChild(l)
        }
        return n
    }

    function i() {
        var t = o[c.skillI];
        c.step ? c.step-- : (c.step = g, c.prefixP < l.length ? (c.prefixP >= 0 && (c.text += l[c.prefixP]), c.prefixP++) : "forward" === c.direction ? c.skillP < t.length ? (c.text += t[c.skillP], c.skillP++) : c.delay ? c.delay-- : (c.direction = "backward", c.delay = a) : c.skillP > 0 ? (c.text = c.text.slice(0, -1), c.skillP--) : (c.skillI = (c.skillI + 1) % o.length, c.direction = "forward")), r.textContent = c.text, r.appendChild(n(c.prefixP < l.length ? Math.min(s, s + c.prefixP) : Math.min(s, t.length - c.skillP))), setTimeout(i, d)
    }
    var l = "",
        o = ["无论蓬户荆扉", "都将因你的倚闾", "而成为我的凯旋门", "生活琐碎", "三两烈酒"].map(function (r) {
            return r + "."
        }),
        a = 2,
        g = 1,
        s = 5,
        d = 75,
        b = ["rgb(110,64,170)", "rgb(150,61,179)", "rgb(191,60,175)", "rgb(228,65,157)", "rgb(254,75,131)", "rgb(255,94,99)", "rgb(255,120,71)", "rgb(251,150,51)", "rgb(226,183,47)", "rgb(198,214,60)", "rgb(175,240,91)", "rgb(127,246,88)", "rgb(82,246,103)", "rgb(48,239,130)", "rgb(29,223,163)", "rgb(26,199,194)", "rgb(35,171,216)", "rgb(54,140,225)", "rgb(76,110,219)", "rgb(96,84,200)"],
        c = {
            text: "",
            prefixP: -s,
            skillI: 0,
            skillP: 0,
            direction: "forward",
            delay: a,
            step: g
        };
    i()
};
binft(document.getElementById('binft'));
</script>

第四款 网站运营时间统计

第一种

<p>已苟活世界 <b> <strong> <script language="JavaScript" type ="text/javascript"> var urodz = new Date("12/07/2017"); var now = new Date(); var ile = now.getTime() - urodz.getTime(); var dni = Math.floor(ile / (1000 * 60 * 60 * 24)); document.write( + dni) </script> </strong> </b> 天</p>

第二种为 (像时钟一样走动)

合适位置添加 <span>博客已运行</span><span id=bin_tm></span>
引入 JavaScript

<script type="text/javascript">
function show_date_time(){window.setTimeout("show_date_time()",1e3);var BirthDay=new Date("2016/06/06 00:00:00"),today=new Date,timeold=today.getTime()-BirthDay.getTime(),msPerDay=864e5,e_daysold=timeold/msPerDay,daysold=Math.floor(e_daysold),e_hrsold=24*(e_daysold-daysold),hrsold=Math.floor(e_hrsold),e_minsold=60*(e_hrsold-hrsold),minsold=Math.floor(60*(e_hrsold-hrsold)),seconds=Math.floor(60*(e_minsold-minsold));bin_tm.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";}
show_date_time();</script>

第五款 复制弹窗提示 (来自 XSY)

引入 js

<script src="//cdn.hap5.top/code/layer/layer.js"></script>

并且在自定义 JavaScript 中添加

<script type="text/javascript">
        document.body.oncopy = function() {layer.msg('复制成功,若要转载请务必保留原文链接!');};  
</script>

第六款 打字特效

<script src="//demo.fooor.cn/js/activate-power-mode.js "></script>  
<script>  
POWERMODE.colorful = true;  // 是否开启冒光特效  
POWERMODE.shake = false;    // 是否开启抖动特效  
document.body.addEventListener('input', POWERMODE); 
</script> 

第七款 页面滚动顶部进度条加载效果代码

<div class="test"></div>
<script src="jquery.min.js"></script>
<script src="headBand.min.js"></script>
<script>
$('.test').headBand({//
    'background':'#008aff',//颜色
    'height':"1"//宽度
});
</script>

下载地址:点击下载 提取码:acat

第八款 标题打字特效

<!--标题打字特效引入-->
<p id ="typetitle">可能我在也不会遇到第二这样的她</p>
 <script>
            var typingbefore = document.getElementById("typetitle").innerText;//获取标题内容
            document.getElementById('typetitle').innerText = "";//将标题内容赋值为空
            var i = 0;
            function typetitle(){
                var typingafter = document.getElementById('typetitle');//获取标题元素
                if(i <= typingbefore.length){
                    typingafter.innerHTML = typingbefore.slice(0,i++)+'|';//将标题内容通过slice()方法返回
                    setTimeout('typetitle()',100);//每100毫秒执行一次
                }else{
                    typingafter.innerHTML = typingbefore;//当标题内容全部返回后,去掉最后的‘|’
                }
            }
            typetitle();
            </script>

第九款 文字抖动效果

<link rel="stylesheet" href="doudong.css">
<p id="shaky" class="shaky c">十一♥</p>
<span class="shaky" ><p id="shaky">(●'◡'●)ノ</p></span>

暂时没有第十款了

如果本文对您有用的话,欢迎在下方留言评论哦~

(๑´ㅂ`๑) 已有5人微信打赏,心情+5...

网站折腾 之 javascript

timg.jpg
以下代码均不知原作者
来源网络 整理修改
实在太长了 可以通过右侧目录书查看
下载地址在文中

第一款 给网站添加点击特效 心

<script type="text/javascript">
    !function (e, t, a) {
    function r() {
    for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
    requestAnimationFrame(r)
    }
    function n() {
    var t = "function" == typeof e.onclick && e.onclick;
    e.onclick = function (e) {
    t && t(), o(e)
    }
    }
    function o(e) {
    var a = t.createElement("div");
    a.className = "heart", s.push({
    el: a,
    x: e.clientX - 5,
    y: e.clientY - 5,
    scale: 1,
    alpha: 1,
    color: c()
    }), t.body.appendChild(a)
    }
    function i(e) {
    var a = t.createElement("style");
    a.type = "text/css";
    try {
    a.appendChild(t.createTextNode(e))
    } catch (t) {
    a.styleSheet.cssText = e
    }
    t.getElementsByTagName("head")[0].appendChild(a)
    }
    function c() {
    return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
    }
    var s = [];
    e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
    setTimeout(e, 1e3 / 60)
    }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
    }(window, document);
    </script>

第二款 网站焦点监控

<script>
var OriginTitile = document.title,
titleTime;
document.addEventListener("visibilitychange",
function() {
    if (document.hidden) {
        $;
        document.title = "哼 讨厌 你怎么走了吖 o_O!";
        clearTimeout(titleTime)
    } else {
        $;
        document.title = "呀呀呀 回来了!" + OriginTitile;
        titleTime = setTimeout(function() {
            document.title = OriginTitile
        },
        2000)
    }
});
</script>

另外一种

<script>
    var originalTitle = document.title;
    window.onblur = function(){document.title = '要玩捉迷藏吗'};
    window.onfocus = function(){document.title = originalTitle};
</script>

第三款 闪烁字体

在适当位置添加 <p id="binft"></p>
引入 JavaScript

<script>
var binft = function (r) {
    function t() {
        return b[Math.floor(Math.random() * b.length)]
    }

    function e() {
        return String.fromCharCode(94 * Math.random() + 33)
    }

    function n(r) {
        for (var n = document.createDocumentFragment(), i = 0; r > i; i++) {
            var l = document.createElement("span");
            l.textContent = e(), l.style.color = t(), n.appendChild(l)
        }
        return n
    }

    function i() {
        var t = o[c.skillI];
        c.step ? c.step-- : (c.step = g, c.prefixP < l.length ? (c.prefixP >= 0 && (c.text += l[c.prefixP]), c.prefixP++) : "forward" === c.direction ? c.skillP < t.length ? (c.text += t[c.skillP], c.skillP++) : c.delay ? c.delay-- : (c.direction = "backward", c.delay = a) : c.skillP > 0 ? (c.text = c.text.slice(0, -1), c.skillP--) : (c.skillI = (c.skillI + 1) % o.length, c.direction = "forward")), r.textContent = c.text, r.appendChild(n(c.prefixP < l.length ? Math.min(s, s + c.prefixP) : Math.min(s, t.length - c.skillP))), setTimeout(i, d)
    }
    var l = "",
        o = ["无论蓬户荆扉", "都将因你的倚闾", "而成为我的凯旋门", "生活琐碎", "三两烈酒"].map(function (r) {
            return r + "."
        }),
        a = 2,
        g = 1,
        s = 5,
        d = 75,
        b = ["rgb(110,64,170)", "rgb(150,61,179)", "rgb(191,60,175)", "rgb(228,65,157)", "rgb(254,75,131)", "rgb(255,94,99)", "rgb(255,120,71)", "rgb(251,150,51)", "rgb(226,183,47)", "rgb(198,214,60)", "rgb(175,240,91)", "rgb(127,246,88)", "rgb(82,246,103)", "rgb(48,239,130)", "rgb(29,223,163)", "rgb(26,199,194)", "rgb(35,171,216)", "rgb(54,140,225)", "rgb(76,110,219)", "rgb(96,84,200)"],
        c = {
            text: "",
            prefixP: -s,
            skillI: 0,
            skillP: 0,
            direction: "forward",
            delay: a,
            step: g
        };
    i()
};
binft(document.getElementById('binft'));
</script>

第四款 网站运营时间统计

第一种

<p>已苟活世界 <b> <strong> <script language="JavaScript" type ="text/javascript"> var urodz = new Date("12/07/2017"); var now = new Date(); var ile = now.getTime() - urodz.getTime(); var dni = Math.floor(ile / (1000 * 60 * 60 * 24)); document.write( + dni) </script> </strong> </b> 天</p>

第二种为 (像时钟一样走动)

合适位置添加 <span>博客已运行</span><span id=bin_tm></span>
引入 JavaScript

<script type="text/javascript">
function show_date_time(){window.setTimeout("show_date_time()",1e3);var BirthDay=new Date("2016/06/06 00:00:00"),today=new Date,timeold=today.getTime()-BirthDay.getTime(),msPerDay=864e5,e_daysold=timeold/msPerDay,daysold=Math.floor(e_daysold),e_hrsold=24*(e_daysold-daysold),hrsold=Math.floor(e_hrsold),e_minsold=60*(e_hrsold-hrsold),minsold=Math.floor(60*(e_hrsold-hrsold)),seconds=Math.floor(60*(e_minsold-minsold));bin_tm.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";}
show_date_time();</script>

第五款 复制弹窗提示 (来自 XSY)

引入 js

<script src="//cdn.hap5.top/code/layer/layer.js"></script>

并且在自定义 JavaScript 中添加

<script type="text/javascript">
        document.body.oncopy = function() {layer.msg('复制成功,若要转载请务必保留原文链接!');};  
</script>

第六款 打字特效

<script src="//demo.fooor.cn/js/activate-power-mode.js "></script>  
<script>  
POWERMODE.colorful = true;  // 是否开启冒光特效  
POWERMODE.shake = false;    // 是否开启抖动特效  
document.body.addEventListener('input', POWERMODE); 
</script> 

第七款 页面滚动顶部进度条加载效果代码

<div class="test"></div>
<script src="jquery.min.js"></script>
<script src="headBand.min.js"></script>
<script>
$('.test').headBand({//
    'background':'#008aff',//颜色
    'height':"1"//宽度
});
</script>

下载地址:点击下载 提取码:acat

第八款 标题打字特效

<!--标题打字特效引入-->
<p id ="typetitle">可能我在也不会遇到第二这样的她</p>
 <script>
            var typingbefore = document.getElementById("typetitle").innerText;//获取标题内容
            document.getElementById('typetitle').innerText = "";//将标题内容赋值为空
            var i = 0;
            function typetitle(){
                var typingafter = document.getElementById('typetitle');//获取标题元素
                if(i <= typingbefore.length){
                    typingafter.innerHTML = typingbefore.slice(0,i++)+'|';//将标题内容通过slice()方法返回
                    setTimeout('typetitle()',100);//每100毫秒执行一次
                }else{
                    typingafter.innerHTML = typingbefore;//当标题内容全部返回后,去掉最后的‘|’
                }
            }
            typetitle();
            </script>

第九款 文字抖动效果

<link rel="stylesheet" href="doudong.css">
<p id="shaky" class="shaky c">十一♥</p>
<span class="shaky" ><p id="shaky">(●'◡'●)ノ</p></span>

暂时没有第十款了

发表你的评论
选择表情