/** * @description: 网站公共脚本 * @author: ishang_pan * @update: ishang_pan (2020-06-16 09:25) */ //设为首页 function SetHome(url){ if (document.all) { document.body.style.behavior='url(#default#homepage)'; document.body.setHomePage(url); }else{ alert("您好,您的浏览器不支持自动设置页面为首页功能,请您手动在浏览器里设置该页面为首页!"); } } //加入收藏 function AddFavorite(sURL, sTitle) { sURL = encodeURI(sURL); try{ window.external.addFavorite(sURL, sTitle); }catch(e) { try{ window.sidebar.addPanel(sTitle, sURL, ""); }catch (e) { alert("加入收藏失败,请使用Ctrl+D进行添加,或手动在浏览器里进行设置."); } } } //选项卡 $(function(){ $('.tit-switch').children().children("li").mouseover(function(){ $(this).addClass('u-active').siblings().removeClass('u-active'); $(this).parent().parent().siblings('.list-switch').hide().eq($(this).index()).show(); }); }); //返回顶部 $(function () { $('.j-goTop').click(function(){ $('body,html').animate({scrollTop:0},800); return false; }); }); // 导航 // $('.u-yjnav').hover(function(){ // $(this).addClass('u-active'); // if($(this).find('.znav li').length===0) return; // $(this).find('.znav').slideDown(); // },function(){ // $(this).removeClass('u-active').find('.znav').slideUp(); // }) // $('.u-searchicon').click(function(){ // $(this).toggleClass('u-active'); // $('.g-search').slideToggle('f-dn'); // }); // $('.u-mdnavbtn').click(function(){ // $(this).toggleClass('u-active'); // $('.m-mdnavs').slideToggle('f-dn'); // }); // $('.u-mdyjli span').click(function(){ // $(this).toggleClass('u-active').parent().siblings('ul').slideToggle('f-dn'); // }); //侧边栏 $(function(){ $(window).scroll(function(){$(window).scrollTop()>400?$(".btop").removeClass('f-dn'):$(".btop").addClass('f-dn');}); $(".menu-item.menu-fifth").click(function(){$("html,body").animate({scrollTop:0},500)}) }); //获取当前年月日 和 星期 $(function () { var myDate = new Date; var year = myDate.getFullYear(); //获取当前年 var mon = myDate.getMonth() + 1; //获取当前月 var date = myDate.getDate(); //获取当前日 // var h = myDate.getHours();//获取当前小时数(0-23) // var m = myDate.getMinutes();//获取当前分钟数(0-59) // var s = myDate.getSeconds();//获取当前秒 var week = myDate.getDay(); var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; $("#nowDate").html(year + "年" + (mon<10?('0'+mon):mon) + "月" + (date<10?('0'+date):date) + "日 "); $("#nowWeek").html(weeks[week]) }); //非政府网站跳转提示 function getHost(url) { var host = ""; if (typeof url == "undefined" || null == url) url = window.location.host; var regex = /^\/[\w\/]*/; var match = url.match(regex); if (typeof match != "undefined" && null != match) host = window.location.host; return host; }; $(function(){ var domain = 'gov.cn',ignore = window.location.hostname; $('a[href]').click(function(){ var o = $(this); var url = o.attr('href'),host = getHost(url); if(url == undefined || url == '' ){ return false; } if ((host.indexOf(domain) == -1 && host.indexOf(ignore) == -1 && url.indexOf(domain) == -1 && url.indexOf(ignore) == -1 && url.indexOf("javascript") && url.indexOf('#') == -1 && url != "#")||$(this).attr("data-outer") == 1 ||$(this).find("img").attr("data-bd-imgshare-binded") == 1){ $(this).attr({'target':'_self','href':'javascript:;'}); var w = '480px'; var h = 'auto'; if(window.screen.width < 768){ w = '90%'; h = 'auto'; } var cf = layer.confirm('