<!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>打開網(wǎng)1秒之后彈出屏幕居中的浮動(dòng)層</title> <style type="text/css"> body{ margin:0; padding:0;} #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;} #box p{padding:0 10px;margin-top:10px;} #box span{color:#ff0;padding-left:5px;} #box h2{ margin:0;height:25px;cursor:move;background:#222;border-bottom:2px solid #ccc;text-align:right;padding:0 10px;} #box h2 a{color:#fff;font:12px/25px Arial;text-decoration:none;outline:none;} </style> <script type="text/javascript"> window.onload=function() { setTimeout(function() { level(); },1000); }; function level() { var oBox=document.getElementById('box'); var oH2=oBox.getElementsByTagName('h2')[0]; oBox.style.display='block'; oH2.onclick=function() { oBox.style.display='none'; }; } </script> </head> <body> <div id="box"> <h2><a href="javascript:;">X</a></h2> 123456789 </div> </body> </html>