图片是跟代码在同一个文件夹下的。<html>
<head>
<meta http-equiv="Content-Type" content="text/html";charset=gb2312"/>
<title>图片淡入淡出</title>
<SCRIPT language="javascript">
<!--
var d=0;
function image(ob){
if(d==0)
{ob.filter.alpha.opacity+=1
}
else
{ob.filter.alpha.opacity-=1
}
if(ob.filter.alpha.opacity==100)
{d=1;
}
else
{if(ob.filter.apha.opacity==0)
d=0;
}
}
}
setInterval("image(u)",10)
//-->
</script>
</head>
<body>
<IMG src="2.jpg" name=u width="300" height="300" style="FILTER: alpha(opacity=0)">
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html";charset=gb2312"/>
<title>图片淡入淡出</title>
<SCRIPT language="javascript">
<!--
var d=0;
function image(ob){
if(d==0)
{ob.filter.alpha.opacity+=1
}
else
{ob.filter.alpha.opacity-=1
}
if(ob.filter.alpha.opacity==100)
{d=1;
}
else
{if(ob.filter.apha.opacity==0)
d=0;
}
}
}
setInterval("image(u)",10)
//-->
</script>
</head>
<body>
<IMG src="2.jpg" name=u width="300" height="300" style="FILTER: alpha(opacity=0)">
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html";charset="gb2312"/>
<title>dddddddd</title>
<SCRIPT language="javascript">var ob;
var d=0;
function image(){
if(d==0){
ob.filters.alpha.opacity+=1
}else{
ob.filters.alpha.opacity-=1
}
if(ob.filters.alpha.opacity==100){
d=1;
}else{
if(ob.filters.alpha.opacity==0)
d=0;
}
document.getElementById("txt1").value=ob.filters.alpha.opacity;
}
window.onload=function(){
ob=document.getElementsByName("u")[0];
setInterval(image,10);
}</script>
</head>
<body>
<input id=txt1>
<IMG src="menu_bg_03.gif" name=u width="300" height="300" style="FILTER: alpha(opacity=0)">
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html";charset="gb2312"/>
<title>dddddddd</title>
<SCRIPT language="javascript">var ob;
var d=0;
function image(){
if(d==0){
ob.filters.alpha.opacity+=1
}else{
ob.filters.alpha.opacity-=1
}
if(ob.filters.alpha.opacity==100){
d=1;
}else{
if(ob.filters.alpha.opacity==0)
d=0;
}
}
window.onload=function(){
ob=document.getElementsByName("u")[0];
setInterval(image,10);
}</script>
</head>
<body>
<IMG src="2.gif" name=u width="300" height="300" style="FILTER: alpha(opacity=0)">
</body>
</html>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js测试</title>
<script src="jquery-1.3.2.js"></script>
<script>
$(document).ready(function(){
$("#btn").toggle(function(){
//$("#test_img").css("opacity", 0).hide(3000);
$("#test_img").hide(3000);
},function(){
// $("#test_img").css("opacity", 1).show(3000);
$("#test_img").show(3000);
});
});
</script>
</head>
<body>
<IMG id="test_img" src="1.jpg" name=u width="300" height="300" style="FILTER: alpha(opacity=0)">
<input type="button" value="点击" id="btn" />
</body>
</html>