MediaWiki:Common.js

来自太阳花Wiki
跳转至: 导航搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */

/* backtotop */
var snowId = document.getElementById("footer");
var solfId = document.createElement("a");
solfId.setAttribute("id","gotop");
solfId.setAttribute("title","回到顶部");
snowId.appendChild(solfId);
 
function goTop(){
    $(window).scroll(function(e) {
//若滚动条离顶部大于10元素
    if($(window).scrollTop()>10)
    $("#gotop").fadeIn(0);//以0秒的间隔渐显id=gotop的元素
    else
    $("#gotop").fadeOut(0);//以0秒的间隔渐隐id=gotop的元素
    });
};
$(function(){
    //点击回到顶部的元素
    $("#gotop").click(function(e) {
        //以1秒的间隔返回顶部
        $('body,html').animate({scrollTop:0},100);
    });
    $("#gotop").mouseover(function(e) {
        $(this).css("background","url(/skins/Aimo/totop.png) no-repeat 0px -100px");
    });
    $("#gotop").mouseout(function(e) {
        $(this).css("background","url(/skins/Aimo/totop.png) no-repeat 0px 0px");
    });
    goTop();//实现回到顶部元素的渐显与渐隐
});