用div的改了下,有效果...<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3 </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script>
function getStyle(elem,name)
{
if(elem.style[name])
{
return elem.style[name];
}
else if(elem.currentStyle)
{
return elem.currentStyle[name];
}
else if(elem.defaultView&&document.defaultView.getComputedStyle)
{
name=name.replace(/([A-Z])/g,"-$1");
name=name.toLowerCase();
var s=document.defaultView.getComputedStyle[elem,""];
return s&&s.getPropertyValue(name);
}
else
return null;
} // Set an opacity level for an element
// (where level is a number 0-100)
function setOpacity( elem, level ) {
// If filters exist, then this is IE, so set the Alpha filter
if ( elem.filters )
elem.filters.alpha.opacity = level; // Otherwise use the W3C opacity property
else
elem.style.opacity = level / 100;
} /* function setOpacity(elem,level)
{
if(elem.filters)
{
elem.style.filters='alpha(opacity='+level+')';
}
else
elem.style.opacity=level/100;
}*/ function fadeIn( elem ) {
// Start the opacity at 0
setOpacity( elem, 0 ); // Show the element (but you can see it, since the opacity is 0)
//show( elem ); // Weユre going to do a 20 ヤframeユ animation that takes
// place over one second
for ( var i = 0; i <= 100; i += 5 ) {
// A closure to make sure that we have the right ヤiユ
(function(){
var pos = i; // Set the timeout to occur at the specified time in the future
setTimeout(function(){ // Set the new opacity of the element
setOpacity( elem, pos ); }, ( pos + 1 ) * 10 );
})();
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Label id="lblText" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 144px" runat="server" Width="336px" Height="72px">显示效果 </asp:Label>
<div id="divText" style="filter:alpha(opacity=100);Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 144px; width:336px; height:72px">显示效果</div>
<INPUT style="Z-INDEX: 102; LEFT: 328px; POSITION: absolute; TOP: 368px" type="button" value="Button" onClick="fadeIn(document.getElementById('divText'));">
</form>
</body>
</HTML>
<HTML>
<HEAD>
<title>WebForm3 </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script>
function getStyle(elem,name)
{
if(elem.style[name])
{
return elem.style[name];
}
else if(elem.currentStyle)
{
return elem.currentStyle[name];
}
else if(elem.defaultView&&document.defaultView.getComputedStyle)
{
name=name.replace(/([A-Z])/g,"-$1");
name=name.toLowerCase();
var s=document.defaultView.getComputedStyle[elem,""];
return s&&s.getPropertyValue(name);
}
else
return null;
} // Set an opacity level for an element
// (where level is a number 0-100)
function setOpacity( elem, level ) {
// If filters exist, then this is IE, so set the Alpha filter
if ( elem.filters )
elem.filters.alpha.opacity = level; // Otherwise use the W3C opacity property
else
elem.style.opacity = level / 100;
} /* function setOpacity(elem,level)
{
if(elem.filters)
{
elem.style.filters='alpha(opacity='+level+')';
}
else
elem.style.opacity=level/100;
}*/ function fadeIn( elem ) {
// Start the opacity at 0
setOpacity( elem, 0 ); // Show the element (but you can see it, since the opacity is 0)
//show( elem ); // Weユre going to do a 20 ヤframeユ animation that takes
// place over one second
for ( var i = 0; i <= 100; i += 5 ) {
// A closure to make sure that we have the right ヤiユ
(function(){
var pos = i; // Set the timeout to occur at the specified time in the future
setTimeout(function(){ // Set the new opacity of the element
setOpacity( elem, pos ); }, ( pos + 1 ) * 10 );
})();
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Label id="lblText" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 144px" runat="server" Width="336px" Height="72px">显示效果 </asp:Label>
<div id="divText" style="filter:alpha(opacity=100);Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 144px; width:336px; height:72px">显示效果</div>
<INPUT style="Z-INDEX: 102; LEFT: 328px; POSITION: absolute; TOP: 368px" type="button" value="Button" onClick="fadeIn(document.getElementById('divText'));">
</form>
</body>
</HTML>
onClick="fadeIn(document.getElementById('divText'));".Net的服务器控件生成html后,ID可能会改变,