var browser; var _topHeight = 0; var _scrollTop = 0; $(function () { browser = { versions: function () { var u = navigator.userAgent, app = navigator.appVersion; return {//移动终端浏览器版本信息 trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核 mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器 iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器 iPad: u.indexOf('iPad') > -1, //是否iPad webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部 }; } (), language: (navigator.browserLanguage || navigator.language).toLowerCase() } // // // _topHeight = $("div.da20").height(); // if (top_nav == 0) { // $("div.nav-wrap").css({ "top": _topHeight + "px" }); // $("div.m-top-wrap").css({ "top": _topHeight + "px" }); // } // $(window).resize(function () { //当浏览器大小变化时 // _topHeight = $("div.da20").height(); // _scrollTop = $(window).scrollTop(); // if (top_nav == 0) { // if (_scrollTop > _topHeight) { // $("div.nav-wrap").css({ "top": "0px" }); // $("div.m-top-wrap").css({ "top": "0px" }); // } else if (_scrollTop > 0 && _scrollTop <= _topHeight) { // var htop = _topHeight - _scrollTop; // $("div.nav-wrap").css({ "top": htop + "px" }); // $("div.m-top-wrap").css({ "top": htop + "px" }); // } else { // $("div.nav-wrap").css({ "top": _topHeight + "px" }); // $("div.m-top-wrap").css({ "top": _topHeight + "px" }); // } // } // }); $(window).scroll(function () { _scrollTop = $(window).scrollTop(); // if (top_nav == 0) { // var htop = _topHeight - _scrollTop; // if (htop <= 0) { // $("div.nav-wrap").addClass("nav-wrap-activate"); // $("div.nav-wrap").css({ "top": "0px" }); // $("div.m-top-wrap").addClass("m-top-wrap-activate"); // $("div.m-top-wrap").css({ "top": "0px" }); // } else { // $("div.nav-wrap").removeClass("nav-wrap-activate"); // $("div.nav-wrap").css({ "top": htop + "px" }); // $("div.m-top-wrap").removeClass("m-top-wrap-activate"); // $("div.m-top-wrap").css({ "top": htop + "px" }); // } // } else { if (_scrollTop >= 1) { $("div.nav-wrap").addClass("nav-wrap-activate"); $("div.m-top-wrap").addClass("m-top-wrap-activate"); } else { $("div.nav-wrap").removeClass("nav-wrap-activate"); $("div.m-top-wrap").removeClass("m-top-wrap-activate"); } //} }) //顶部菜单 $("#menu" + top_nav).eq(0).addClass("activate"); $("#top-" + left_nav).addClass("activate"); $(".top-" + left_nav).addClass("activate"); $("#bottomenu" + top_nav).find("a").eq(0).addClass("hover"); $("#menu ul li").hover(function () { var size = $(this).find("div.box-wrap dl dt").length; var _h = 30 * size + 30; $(this).addClass("activate"); //$(this).find("div.bg").css({ "height": _h + "px" }); $(this).find("div.bg").stop(true, true).slideDown(400); $(this).find("div.box-wrap").stop(true, true).slideDown(400); }, function () { $(this).removeClass("activate"); //$(this).find("div.bg").css({ "height": "0px" }); $(this).find("div.bg").stop(true, true).slideUp(200); $(this).find("div.box-wrap").stop(true, true).slideUp(200); $("#menu" + top_nav).eq(0).addClass("activate"); }); //手机版导航 $("div.btn-menu").click(function () { $(this).hide(); $("div.btn-close-menu").show(); $("div.m-top-wrap").css({ "background-color": "#0062ac" }); $("div.mob-nav").show(100); }); //手机版导航关闭 $("div.btn-close-menu").click(function () { $(this).hide(); $("div.btn-menu").show(); $("div.m-top-wrap").css({ "background": "" }); $("div.mob-nav").hide(100); }); $("div.nav li").click(function () { $("div.nav dl").hide(); $(this).parent().next("dl").slideToggle("slow"); }); $(document).keyup(function (event) { if (event.keyCode == 13) { SearchNewsM(); } }); $("#btnAllSearchM").click(function () { SearchNewsM(); }); }); function SearchNewsM() { var keyword = $("#txtTitleConM").val(); if (keyword == null || keyword == "" || keyword.length < 2 || keyword.length > 30 || keyword == "请输入搜索关键字") { layer.msg("请输入搜索关键字"); return false; } else { checkText("txtTitleConM", keyword); } //window.open('Search.aspx?SearchText=' + escape($("#txtTitleConM").val()) + ''); } function checkText(id, text) {//xss攻击特殊字符过滤 var arr = new Array(); arr = ["alert", "eval", "", "onblur", "onload", "onfocus", "onerror", "onclick", "onMouseOver", "onMouseOut", "onSelect", "onChange", "onSubmit", "console", "href", "", "", "", "", "", "", "", "", "", "", "document", "location", "javascript"]; $.each(arr, function (index, value) { if (text.indexOf(value) != -1) { layer.msg("输入信息包含" + value + "特殊字符"); $('#' + id).val(""); $('#' + id).focus(); return false; } window.location.href = "Search.aspx?SearchText=" + escape(text) + ""; }); }