[原创]Jquery(兼容IE,谷歌,火狐)无效图片替换为可视图片
Jquery(兼容IE,谷歌,火狐)无效图片替换为可视图片
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>(兼容IE,谷歌,火狐)无效图片替换为可视图片</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(function()
{
$("img").each(function()
{
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
if (window.ActiveXObject)
{
if((typeof this.naturalWidth != "undefined" && this.naturalWidth == 0 ) || this.readyState == 'uninitialized' )
{
$(this).attr("src","可视有效图片");
}
}
else
{
$(this).error(function()
{
$(this).attr("src","可视有效图片");
});
}
});
});
</script>
</head>
<body>
<img src="图片1" />
<img src="图片2" />
<img src="图片3" />
<img src="图片4" />
</body>
</html>

浙公网安备 33010602011771号