---
title: "使网页变灰，支持IE、FireFox、Opera、360浏览器等"
author: "xiaojiit"
date: "2011-12-06T10:44:43Z"
tags: []
categories: ["Web前端"]
slug: "ie-firefox-opera-360"
draft: false
lastmod: "2011-12-06T10:46:29Z"
id: 1293475
url: "https://sharejava.iteye.com/blog/1293475"
---

1、对IE的支持，只需要在CSS中添加如下代码：

 

html{  
      filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);  
}

 

 

2、对Firefox、Opera的支持，需要使用JS了，JS文件作者：[http://james.padolsey.com/](http://james.padolsey.com/)

 

      FF中的效果图：[http://james.padolsey.com/demos/grayscale/](http://james.padolsey.com/demos/grayscale/)

 

     下载附件中的grayscale.js，之后，在页面中加入：

 

 

$(document).ready(function () {  
        grayscale($("body"));  
});

 

3、对于Chrome浏览器，不能支持，原因如grayscale的作者所述：

 

GRAYSCALE.JS 写道

Successfully tested in Opera 9, FF2/3, Safari 4, IE6/7. It only works slightly in Safari&lt;4 and Chrome because of their lacking support of CanvasContext.getImageData (because of this, images cannot be grayscaled).