$(function(){ //修改标题 //document.title="北京大学教育学院"; //加载头部 /* $.get("./seg/header.seg",function(data){ $("header").html(data); },"html");*/ /*var _filename_ = location.pathname.match(/[^\/]+$/); if (_filename_ != null && _filename_.length == 1) { var _id_ = _filename_[0].match(/^[^_\.]+/); if (_id_ != null && _id_.length > 0) { $("#" + _id_).addClass("current"); } }*/ /*$(".ssubNav").click(function(){ $("#mobileNav").toggle(300); });*/ $(".ssubNav").click(function(){ if($("#mobileNav").css("display")=="none") { $("#navline_1").addClass("navline1"); $("#navline_2").addClass("navline2"); $("#navline_3").addClass("navline3"); }else{ $("#navline_1").removeClass("navline1"); $("#navline_2").removeClass("navline2"); $("#navline_3").removeClass("navline3"); } $("#mobileNav").toggle(300); }); $(".header .nav #nav li").hover(function(){ $(this).children("ul").slideDown(200); }, function(){ $(this).children("ul").slideUp(200); } ); /*$(".header .logo a.sub_logo").hover(function(){ $(this).children("img").attr("src","img/gse-logo-grey.png"); }, function(){ $(this).children("img").attr("src","img/gse-logo.png"); } ); $(".header .logo1 a.sub_logo").hover(function(){ $(this).children("img").attr("src","../img/gse-logo-grey.png"); }, function(){ $(this).children("img").attr("src","../img/gse-logo.png"); } ); $(".header .logo2 a.sub_logo").hover(function(){ $(this).children("img").attr("src","../../img/gse-logo-grey.png"); }, function(){ $(this).children("img").attr("src","../../img/gse-logo.png"); } ); $(".header .logo3 a.sub_logo").hover(function(){ $(this).children("img").attr("src","../../../img/gse-logo-grey.png"); }, function(){ $(this).children("img").attr("src","../../../img/gse-logo.png"); } ); $(".header .logo a:first-child").hover(function(){ $(this).children("img").attr("src","img/pkulogo_grey.png"); }, function(){ $(this).children("img").attr("src","img/pkulogo_white.png"); } ); $(".header .logo1 a:first-child").hover(function(){ $(this).children("img").attr("src","../img/pkulogo_grey.png"); }, function(){ $(this).children("img").attr("src","../img/pkulogo_white.png"); } ); $(".header .logo2 a:first-child").hover(function(){ $(this).children("img").attr("src","../../img/pkulogo_grey.png"); }, function(){ $(this).children("img").attr("src","../../img/pkulogo_white.png"); } ); $(".header .logo3 a:first-child").hover(function(){ $(this).children("img").attr("src","../../../img/pkulogo_grey.png"); }, function(){ $(this).children("img").attr("src","../../../img/pkulogo_white.png"); } );*/ //加载尾部 /* $.get("./seg/footer.seg",function(data){ $("footer").html(data); },"html"); */ //加载右部 //$.get("./seg/right.seg",function(data){ // $("#right_col").html(data); //},"html"); autoHideMobileNav(); gotoTop(); }); function gotoTop(min_height){ //预定义返回顶部的html代码,它的css样式默认为不显示 var gotoTop_html = '
'; //将返回顶部的html代码插入页面尾部元素前 $(gotoTop_html).insertBefore(".footer"); $("#gotoTop").click(//定义返回顶部点击向上滚动的动画 function(){$('html,body').animate({scrollTop:0},700); }).hover(//为返回顶部增加鼠标进入的反馈效果,用添加删除css类实现 function(){$(this).addClass("hover");}, function(){$(this).removeClass("hover"); }); //获取页面的最小高度,无传入值则默认为600像素 min_height ? min_height = min_height : min_height = 600; //为窗口的scroll事件绑定处理函数 $(window).scroll(function(){ //获取窗口的滚动条的垂直位置 var s = $(window).scrollTop(); //当窗口的滚动条的垂直位置大于页面的最小高度时,让返回顶部元素渐现,否则渐隐 if( s > min_height){ $("#gotoTop").fadeIn(100); }else{ $("#gotoTop").fadeOut(200); }; }); } function autoHideMobileNav(){ $(window).resize(function() { var win_width = $(window).width(); if (win_width >= 800) { $("#mobileNav").slideUp(0); } }); }