鼠标神效

    <script type="text/javascript">
        var a_idx = 0;
        jQuery(document).ready(function ($) {
            $("body").click(function (e) {
                var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善");
                var $i = $("<span/>").text(a[a_idx]);
                a_idx = (a_idx + 1) % a.length;
                var x = e.pageX,
                    y = e.pageY;
                $i.css({
                    "z-index": 99999999999999999999999999999,
                    "top": y - 20,
                    "left": x,
                    "position": "absolute",
                    "font-weight": "bold",
                    "color": "#ff6651"
                });
                $("body").append($i);
                $i.animate({
                    "top": y - 180,
                    "opacity": 0
                }, 1500, function () {
                    $i.remove();
                });
            });
        });
    </script>

离开和进入html时改变title

    <script type="javascript">
    var OriginTitile = document.title;
    var titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '(つェ⊂)人呢?快回来! ' + OriginTitile;
            clearTimeout(titleTime);
        }
        else {
            document.title = '(*´∇`*) 你来啦~ ' + OriginTitile;
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            }, 2000);
        }
    });
    </script>

显示网页运行时间

    <script type="javascript">
        function show_runtime(){
        window.setTimeout("show_runtime()",1000);
        X=new Date("08/06/2019 16:22:00");
        Y=new Date();T=(Y.getTime()-X.getTime());M=24*60*60*1000;
        a=T/M;
        A=Math.floor(a);
        b=(a-A)*24;
        B=Math.floor(b);
        c=(b-B)*60;
        C=Math.floor((b-B)*60);
        D=Math.floor((c-C)*60);
        runtime_span.innerHTML="本站勉强运行: "+A+"天"+B+"小时"+C+"分"+D+"秒"}show_runtime();
    </script>

然后在需要显示运行时间的地方加上以下代码即可。
<span id="runtime_span"></span>

Last modification:September 20th, 2019 at 03:52 pm
如果觉得我的文章对你有用,请随意赞赏