"use strict"; // JavaScript Document //按需写入所需的函数名 $(function () { // 用于测试 var h = 0; checkBrowser(); // 阻止默认行为写法,Chrome56以上版本 // document.addEventListener('touchmove', func, isPassive() ? { // capture: false, // passive: false // } : false); }); // 以下不用可以删除 //表单相关 function forms() { //输入框文字清空还原,控制value // $(".deaSearch .inp").focus(function () { if ($(this).val() == this.defaultValue) { $(this).val(""); } }).blur(function () { if ($(this).val() == '') { $(this).val(this.defaultValue); } }); } //简单标签切换 function tabs(tit, box) { /*html结构
内容一
内容二
*/ var $div_li = $(tit).children(); var $box_li = $(box).children(); var i; $box_li.hide(); $div_li.each(function () { if ($(this).hasClass('on')) i = $(this).index(); }); $box_li.eq(i).show(); $div_li.click(function () { $(this).addClass("on").siblings().removeClass("on"); var index = $div_li.index(this); $box_li.eq(index).fadeIn("linear").siblings().hide(); }); } function hover_tabs(tit, box) { /*html结构
内容一
内容二
*/ var $div_li = $(tit).children(); var $box_li = $(box).children(); var i; $box_li.hide(); $div_li.each(function () { if ($(this).hasClass('on')) i = $(this).index(); }); $box_li.eq(i).show(); $div_li.hover(function () { $(this).addClass("on").siblings().removeClass("on"); var index = $div_li.index(this); $box_li.eq(index).stop().fadeIn("linear").siblings().hide(); }, ''); } // 判断浏览器 var checkBrowser = function checkBrowser() { var userAgent = navigator.userAgent.toLowerCase(); var msie9 = /msie 9\.0/i.test(userAgent); var msie8 = /msie 8\.0/i.test(userAgent); var msie7 = /msie 7\.0/i.test(userAgent); var msie6 = /msie 6\.0/i.test(userAgent); var checkHtml = ''; // if (msie9 || msie8 || msie7 || msie6) { // $('body').append(checkHtml); // }; if (msie8) { checkHtml = '
您现在使用的是IE8内核,版本过低!建议您升级到IE9+或者使用极速模式浏览,以体验最佳效果!×
'; $('body').append(checkHtml); } else if (msie7) { checkHtml = '
您现在使用的是IE7内核,版本过低!建议您升级到IE9+或者使用极速模式浏览,以体验最佳效果!×
'; $('body').append(checkHtml); } else if (msie6) { checkHtml = '
您现在使用的是IE6内核,版本过低!建议您升级到IE9+或者使用极速模式浏览,以体验最佳效果!×
'; $('body').append(checkHtml); } checkBrowser.close = function () { $('.checkBrowser').remove(); }; }; // 判断是否移动设备 var isMobile = function isMobile() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { return true; } else { return false; } }; function func(e) { e.preventDefault(); } $(function () { // $('.site-nav').hover(function() { // $('.site-nav-sub').stop().slideDown(); // }) // $('.site-nav-sub').hover('', function() { // $('.site-nav-sub').stop().slideUp(); // }) $('.J_gotop').on('click', function () { $('html,body').animate({ 'scrollTop': 0 }, 1000); }); $('.J_shou').on('click', function () { $('.home-fixed-con ul').hide(); }); $('.home-fixed-con .yun').on('click', function () { $('.home-fixed-con ul').toggle(); }); $('.site-header .search-btn').on('click', function () { $(this).toggleClass('on'); if ($(this).hasClass('on')) { $(this).find('.form-wp').show(); } else { $(this).find('.form-wp').hide(); } }); $('.site-header .form-wp').on('click', function (e) { e.stopPropagation(); }); /* 导航&头部 */ // $(".moblie-head, .moblie-nav").on("touchmove", function(event) { //移动端禁用滚动条 // event.preventDefault(); // }, false); // var iScrollnavMoblie = new IScroll('.moblie-nav-list-box', {}); // $('.moblie-menu').click(function(event) { // $(document).scrollTop(0); // $('.moblie-nav').slideToggle(500, function() { // iScrollnavMoblie.refresh(); // }); // }); // $('.moblie-nav-a').click(function(event) { // if ($(this).next('.moblie-nav2-list').find('div').length != 0) { // if ($(this).parents('.moblie-nav-li').hasClass('moblie-nav-on')) { // $('.moblie-nav2-list').hide(); // $(this).parents('.moblie-nav-li').removeClass('moblie-nav-on'); // } else { // $('.moblie-nav2-list').hide(); // $(this).next('.moblie-nav2-list').show(); // $(this).parents('.moblie-nav-li').addClass('moblie-nav-on') // } // } // }); var mobileScroll; mobileScroll = new IScroll('.moblie-nav-list-box', { click: false, tap: true, preventDefault: false, scrollY: true }); $('.moblie-menu').on('click', function () { $(document).scrollTop(0); $(this).toggleClass('active'); if ($(this).hasClass('active')) { $('#wrapnav').show(); document.addEventListener('touchmove', func, isPassive() ? { capture: false, passive: false } : false); $('.moblie-nav').stop(true, true).slideDown(); } else { document.removeEventListener('touchmove', func, isPassive() ? { capture: false, passive: false } : false); $('.moblie-nav').stop(true, true).slideUp(); } }); $('.moblie-nav-a').on('click', function () { if ($(this).next('.moblie-nav2-list').find('div').length != 0) { if ($(this).parents('.moblie-nav-li').hasClass('moblie-nav-on')) { $(this).next('.moblie-nav2-list').hide(); $(this).parents('.moblie-nav-li').removeClass('moblie-nav-on'); mobileScroll.refresh(); } else { $(this).next('.moblie-nav2-list').show(); $(this).parents('.moblie-nav-li').addClass('moblie-nav-on'); mobileScroll.refresh(); } } }); });