效果:在指定日期自动将网站变成灰色
修改方法:在jquery.js后引入以下代码
Tips:1、如需增加日期,请在 aidaoriarr 中以 mmdd 的格式添加
2、本代码对IE无效,所以如果在哀悼日浏览本站,并且需要看正常颜色,可以选择使用IE浏览器
- if(aidaori()){
- $("html").css({
- "filter":"gray !important",
- "filter":"progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)",
- "filter":"grayscale(100%)",
- "-webkit-filter":"grayscale(100%)",
- "-moz-filter":"grayscale(100%)",
- "-ms-filter":"grayscale(100%)",
- "-o-filter":"grayscale(100%)"
- });
- }
-
- function aidaori(){
- var aidaoriarr=new Array("0403","0404","0405","0406","0414","0512","0807","0909","1213");
- //2020年4月4日 新冠肺炎哀悼日,清明节
- //2010年4月14日,青海玉树地震
- //2008年5月12日,四川汶川地震
- //2010年8月7日,甘肃舟曲特大泥石流
- //1976年9月9日,毛泽东逝世
- //1937年12月13日,南京大屠杀
- var mydate = new Date();
- var str = "";// + mydate.getFullYear();
- var mm = mydate.getMonth()+1;
- if(mydate.getMonth()>9){
- str += mm;
- }else{
- str += "0" + mm;
- }
- if(mydate.getDate()>9){
- str += mydate.getDate();
- }else{
- str += "0" + mydate.getDate();
- }
- if(aidaoriarr.indexOf(str)>-1){
- return 1;
- }else{
- return 0;
- }
- }