The example in this article describes the js advertising code to achieve the curtain effect. Share it with everyone for your reference. The details are as follows:
This is an advertising code with a curtain effect. The advertising image is slowly pulled up like a curtain. It is reduced to a certain size and then freezes. Currently, it can still be seen on some large portals. to this effect.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-lm-style-adv-pic-style-codes/
The specific code is as follows:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>slide</title> <style type="text/css"> html,body{ width:100%; height:100%; margin:0px; border:0px; text-align:center; } div{ margin:auto; overflow:hidden; } </style> </head> <body> <script type="text/javascript"> function tag(obj){ return document.getElementsByTagName(obj)[0]; } window.onload=function(){ setTimeout("slideUp();",1000); } function slideUp(){ if(tag("div").offsetHeight>0){ if(tag("div").offsetHeight>10){ tag("div").style.height=tag("div").offsetHeight-10+"px" setTimeout("slideUp();",20); }else{ tag("div").style.display="none"; tag("img").src="images/wall8.jpg"; tag("div").style.display="block"; slideDown(); } } } function slideDown(){ if(tag("div").offsetHeight<80){ if(tag("div").offsetHeight<70){ tag("div").style.height=tag("div").offsetHeight+10+"px"; setTimeout("slideDown();",20); }else{ tag("div").style.height="80px"; } } } </script> <div><img src="images/wall8.jpg"></div> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.