首页 新闻 会员 周边

关于博客园JS权限申请

2
[已解决问题] 解决于 2018-10-21 16:45

各位园友,请问js权限用来做什么?我看看有必要申请吗

土拨鼠的大白菜的主页 土拨鼠的大白菜 | 菜鸟二级 | 园豆:202
提问于:2018-10-17 18:35
< >
分享
最佳答案
0

你好,获得js权限之后就可以更换自己喜欢的网页主题哦。背景,侧边栏什么的都可以自定义耶。
我当初申请的原因是想在自己的博客网页加入一个来访者的统计控件,看看访客都来自哪里。
另外我还添加了单击鼠标的时候显示爱心的功能,好可爱!
总之,获得js权限之后,土拨鼠的大白菜就可以打造拥有自己风格的博客了。

奖励园豆:5
芽衣 | 菜鸟二级 |园豆:384 | 2018-10-20 14:42

谢谢 现在单击爱心功能还在吗

土拨鼠的大白菜 | 园豆:202 (菜鸟二级) | 2018-10-21 13:35

@土拨鼠的大白菜: 你好,在的,可以到我的播客主页单击空白处就会蹦出小爱心了。

https://www.cnblogs.com/xiaomaolove/

申请js权限之后,在"博客侧边栏公告(支持HTML代码)(支持JS代码)"里加入下面的代码就可以实现爱心特效了。

<!-- 爱心特效 -->
<script type="text/javascript">

(function(window,document,undefined){
        var hearts = [];
        window.requestAnimationFrame = (function(){
                return window.requestAnimationFrame || 
                           window.webkitRequestAnimationFrame ||
                           window.mozRequestAnimationFrame ||
                           window.oRequestAnimationFrame ||
                           window.msRequestAnimationFrame ||
                           function (callback){
                                   setTimeout(callback,1000/60);
                           }
        })();
        init();
        function init(){
                css(".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: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
                attachEvent();
                gameloop();
        }
        function gameloop(){
                for(var i=0;i<hearts.length;i++){
                    if(hearts[i].alpha <=0){
                            document.body.removeChild(hearts[i].el);
                            hearts.splice(i,1);
                            continue;
                    }
                    hearts[i].y--;
                    hearts[i].scale += 0.004;
                    hearts[i].alpha -= 0.013;
                    hearts[i].el.style.cssText = "left:"+hearts[i].x+"px;top:"+hearts[i].y+"px;opacity:"+hearts[i].alpha+";transform:scale("+hearts[i].scale+","+hearts[i].scale+") rotate(45deg);background:"+hearts[i].color;
            }
            requestAnimationFrame(gameloop);
        }
        function attachEvent(){
                var old = typeof window.onclick==="function" && window.onclick;
                window.onclick = function(event){
                        old && old();
                        createHeart(event);
                }
        }
        function createHeart(event){
            var d = document.createElement("div");
            d.className = "heart";
            hearts.push({
                    el : d,
                    x : event.clientX - 5,
                    y : event.clientY - 5,
                    scale : 1,
                    alpha : 1,
                    color : randomColor()
            });
            document.body.appendChild(d);
    }
    function css(css){
            var style = document.createElement("style");
                style.type="text/css";
                try{
                    style.appendChild(document.createTextNode(css));
                }catch(ex){
                    style.styleSheet.cssText = css;
                }
                document.getElementsByTagName('head')[0].appendChild(style);
    }
        function randomColor(){
                return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")";
        }
})(window,document);

</script>
芽衣 | 园豆:384 (菜鸟二级) | 2018-10-21 15:39
其他回答(2)
1

js权限就可以自己写一些js脚本,然后再你博客的每一页都执行, 我之前申请后添加百度统计的代码.

bingxl | 园豆:257 (菜鸟二级) | 2018-10-17 19:13

谢谢回答

支持(0) 反对(0) 土拨鼠的大白菜 | 园豆:202 (菜鸟二级) | 2018-10-17 19:33
1

网站浏览统计、侧边栏公告、生成目录,具体效果可参考我首页:ycyzharry

ycyzharry | 园豆:25653 (高人七级) | 2018-10-18 11:00

谢谢 专家六级

支持(0) 反对(0) 土拨鼠的大白菜 | 园豆:202 (菜鸟二级) | 2018-10-21 13:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册