延迟打开层,打开网页几秒后弹出可关闭的浮动层。在网页打开后的几秒内,弹出一个浮动层,像有些论坛,在打开后会弹出一个让注册的窗口,如果不想马上注册,可以关掉此窗口,本代码正是实现了打开窗口后1秒钟弹出一个浮动窗口,代码简洁易懂。 示例: <!DOCTYPE html><br /> <html xmlns="http://www.w3.org/1999/xhtml"><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /> <title>打开网1秒之后弹出屏幕居中的浮动层</title><br /> <style type="text/css"><br /> body{ margin:0; padding:0;}<br /> #box{width:500px;height:250px; background:#666; border:2px solid #CCC; position:absolute;left:50%;top:50%; margin:-125px 0 0 -250px; z-index:150;display:none;}<br /> #box p{padding:0 10px;margin-top:10px;}<br /> #box span{color:#ff0;padding-left:5px;}<br /> #box h2{ margin:0;height:25px;cursor:move;background:#222;border-bottom:2px solid #ccc;text-align:right;padding:0 10px;}<br /> #box h2 a{color:#fff;font:12px/25px Arial;text-decoration:none;outline:none;}<br /> </style><br /> <script type="text/javascript"><br /> window.onload=function()<br /> {<br /> setTimeout(function()<br /> {<br /> level();<br /> },1000);<br /> };<br /> function level()<br /> {<br /> var oBox=document.getElementById('box');<br /> var oH2=oBox.getElementsByTagName('h2')[0];<br /> oBox.style.display='block';<br /> oH2.onclick=function()<br /> {<br /> oBox.style.display='none';<br /> };<br /> }<br /> </script><br /> </head><br /> <body><br /> <div id="box"><br /> <h2><a href="javascript:;">X</a></h2><br /> 欢迎访问烈火网 Veryhuo,COM<br /> </div><br /> </body><br /> </html><br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>提示:可修改后代码再运行! 文章导航 JS开幕效果,点击按钮层缓缓向上收起,直到消失Css+Div层的展开与收缩、折叠层菜单代码