JS implementation of simple top timing closed layer effect

  • 2020-03-30 03:20:34
  • OfStack

 
<script type="text/javascript"> 
var time = 300; 
var h = 0; 
function addCount() 
{ 
if(time>0) 
{ 
time--; 
h = h+5; 
} 
else 
{ 
return; 
} 
if(h>300) // highly  
{ 
return; 
} 
document.getElementById("ads").style.display = ""; 
document.getElementById("ads").style.height = h+"px"; 
setTimeout("addCount()",30); 
} 
window.onload = function showAds() 
{ 
addCount(); 
setTimeout("noneAds()",7000); //The stay time has been adjusted by myself
} 
var T = 300; 
var N = 300; // highly  
function noneAds() 
{ 
if(T>0) 
{ 
T--; 
N = N-5; 
} 
else 
{ 
return; 
} 
if(N<0) 
{ 
document.getElementById("ads").style.display = "none"; 
return; 
} 
document.getElementById("ads").style.height = N+"px"; 
setTimeout("noneAds()",30); 
} 
</script> 

 
<div style="MARGIN: 0px auto; WIDTH: 900px; BACKGROUND: #369; HEIGHT: 300px; COLOR: #fff" id="ads"> The home of the script _www.jb51.net</div> 

Related articles: