一、以下代码可自动根据设定的日期调整颜色为灰色。可在页面<head></head>中间添加
<script type="text/javascript">
var intYear,intMonth,intDay;
var today;
today=new Date();
intYear=today.getYear();
intMonth=today.getMonth()+1;
intDay=today.getDate();
timeString=intYear+"-"+intMonth+"-"+intDay;
if(timeString=="2010-8-15")
{
document.writeln("<style type=/"text/css/">");
//document.writeln("html { filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }");
document.writeln("*{ filter:Gray;}");
//*可调整更多元素 例如某些弹出的客服框。
document.writeln("</style>");
}
</script>
二、关于网站FLASH变灰色
如果上述代码无法实现变灰色,部分FLASH无法变灰色,具体原因不详。在FLASH代码中可采用以下:
<param value="opaque" name="wmode"/>
想通过JS代码在日期时间自动调整灰色显示,未能实现效果。
三、简单的CSS控制
<style type="text/css">
body {
filter:Gray;
}
</style>
本文介绍了一种使用JavaScript和CSS自动将网页元素变为灰色的方法,并针对特定日期应用此效果。此外,还探讨了使Flash内容灰化的限制及替代方案。
531

被折叠的 条评论
为什么被折叠?



