$( function(){ document.body.addeventlistener('touchstart',function(){}); $(window).bind("load", function() { var footerheight = 0; var footertop = 0; positionfooter(); function positionfooter() { // 获取页脚的高度 footerheight = $(".footer").height(); // 获取页脚的高度 /* scrolltop() 设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离 */ footertop = ($(window).scrolltop()+$(window).height()-footerheight)+"px"; //如果页面内容高度小于屏幕高度,div#footer将绝对定位到屏幕底部,否则div#footer保留它的正常静态定位 if(($(document.body).height()+footerheight) < $(window).height()) { $(".footer").addclass("fixed"); } } $(window).scroll(positionfooter).resize(positionfooter); }); //宽高自适应 img('.autoimg'); function img(e){ $(e).on('load', function() { var width = $(this)[0].naturalwidth var height = $(this)[0].naturalheight if ( width > height ) { $(this).height('100%'); } else { $(this).css("height","auto"); $(this).width('100%') } }) } //返回顶部 var $top = $(".right_slide .back_top a"); $top.click( function(){ $("body,html").animate({ scrolltop: 0 }, 500); return false; } ); $(window).scroll(function(){ if($(document).scrolltop()>$(window).height()){ $(".right_slide .back_top").show(); }else{ $(".right_slide .back_top").hide(); } }) // 小屏幕导航 var $smallnavbtn = $(".small_nav_btn"); var onoff = true; var $smallnav = $(".small_nav"); var $pmask = $(".hidebg"); $smallnavbtn.click( function(){ if( onoff ){ $(this).addclass("active"); $pmask.fadein(200); $smallnav.slidedown(200) $("body").css("overflow","hidden"); $smallnavbtn.find("i").css("background","#000"); }else{ $(this).removeclass("active"); $smallnav.slideup(200) $pmask.fadeout(200); $("body").css("overflow","auto"); $smallnavbtn.find("i").css("background","#000"); } onoff = !onoff; } ); $pmask.click( function(){ // $smallnav.animate({"right":-160},400); $smallnav.slideup(200) $(this).fadeout(400); $("body").css("overflow","auto"); $smallnavbtn.find("i").css("background","#000"); onoff = true } ); // 手机端导航下拉的下拉 $(".small_nav .wapper .btn i").click(function(){ var $this = $(this); if ( $this.next(".show").css("display") == "none" ) { $(".small_nav .show").slideup(200); $(".small_nav .btn").removeclass("active"); $this.next(".show").slidedown(200); $this.parent().addclass("active"); }else{ $this.next(".show").slideup(200); $this.parent().removeclass("active"); } }) function stopevent(){ var e=arguments.callee.caller.arguments[0]||event; if (e && e.stoppropagation) { e.stoppropagation(); } else if (window.event) { window.event.cancelbubble = true; } } })