<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<metahttp-equiv="content-type"content="text/html;charset=UTF-8"/>
<title>让网页变成灰白色</title>
<styletype="text/css">
html{filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);} /*针对IE*/
body{margin:0; padding:0; pink;}
#box{width:500px; height:300px; line-height:300px; text-align:center; color:#f00; border:1px solid green; background:yellow; margin:100px auto;}
</style>
<scriptsrc="grayscale.js"type="text/javascript"></script>
<!--grayscale.js 是一个实现网页元素 “灰度” 效果的js插件,可以运行在大多数的浏览器中,在 Mozilla Firefox 2/3, Safari4, IE6 / 7, Opera 9 中成功运行。-->
<scripttype="text/javascript">
window.onload=function(){
grayscale(document.body);
}
</script>
</head>
<body>
<divid="box">为雅安人民祈福</div>
</body>
</html>
html{filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);}这个是针对IE设置的,调用grayscale.js是针对火狐,谷歌,苹果等浏览器。CSS和JS结合就能兼容各个浏览器了。
大家都来试试吧,为雅安祈福,让你的网页暂时变成灰白色吧!
grayscale.js见附件