日期:2014-05-16 浏览次数:20422 次
JS弹出层/窗口源代码收集,很全的,很好用! <!DOCTYPE html> <html> <head><title>JS弹出层</title> <style> body {margin:0px} #Loading {position:absolute;z-index:10;left:10px;top:10px;border:1px #666666 solid;background:#eeeeee;width:10px;height:10px} </style> <script LANGUAGE="JavaScript"> <!-- function $(){return document.getElementById?document.getElementById(arguments[0]):eval(arguments[0]);} var OverH,OverW,ChangeDesc,ChangeH=50,ChangeW=50; function OpenDiv(_Dw,_Dh,_Desc) { $("Loading").innerHTML=""; OverH=_Dh;OverW=_Dw;ChangeDesc=_Desc; $("Loading").style.display=''; if(_Dw>_Dh){ChangeH=Math.ceil((_Dh-10)/((_Dw-10)/50))}else if(_Dw<_Dh){ChangeW=Math.ceil((_Dw-10)/((_Dh-10)/50))} $("Loading").style.top=(document.documentElement.clientHeight-10)/2+"px"; $("Loading").style.left=(document.documentElement.clientWidth-10)/2+"px"; OpenNow() } var Nw=10,Nh=10; function OpenNow() { if (Nw>OverW-ChangeW)ChangeW=2; if (Nh>OverH-ChangeH)ChangeH=2; Nw=Nw+ChangeW;Nh=Nh+ChangeH; if(OverW>Nw||OverH>Nh) { if(OverW>Nw) { $("Loading").style.width=Nw+"px"; $("Loading").style.left=(document.documentElement.clientWidth-Nw)/2+"px"; } if(OverH>Nh) { $("Loading").style.height=Nh+"px"; $("Loading").style.top=(document.documentElement.clientHeight-Nh)/2+"px" } window.setTimeout("OpenNow()",10) }else{ Nw=10;Nh=10;ChangeH=50;ChangeW=50; $("Loading").innerHTML=ChangeDesc; } } //--> </script> </head> <body> <a href="javascript:OpenDiv(500,300,'层1<br>双击关闭')">层1 500*300</a><br><br> <a href="javascript:OpenDiv(500,200,'层2<br>双击关闭')">层2 500*200</a><br><br> <a href="javascript:OpenDiv(200,500,'层3<br>双击关闭')">层3 200*500</a><br><br> <a href="javascript:OpenDiv(500,500,'层4<br>双击关闭')">层4 500*500</a> <div id="Loading" style="display:none" ondblclick="this.style.display='none'"></div> </body> </html> 可以用鼠标拖动的JS弹出层 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>简单的测试页面</title> <style type="text/css"> <!-- html { height: 100%; } body { margin: 0px; padding: 0px; height: 100%; } #dt_3 { cursor: pointer; } div#mbDIV { position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background-color: #AAAAAA; z-index: 10; filter: alpha(opacity=80);opacity:0.8; } div#loginDIV { position: absolute; width: 300px; height: 150px; background-color: #FFFF00; z-index: 20; } div#loginTopDIV { width: 100%; height: 20px; background-color: #FF0000; cursor: move; } --> </style> <script type="text/javascript"> <!-- function show(ele) { eval(ele + ".style.display = ''"); } function hidden(ele) { eval(ele + ".style.display = 'none'"); } //--> </script> </head> <body> <div style="overflow: hidden;"> <h3>请点击 --> 03号拖拉机</h3> <p id="dt_1">01号拖拉机</p> <p id="dt_2">02号拖拉机</p> <p id="dt_3">03号拖拉机</p> <p id="dt_4">04号拖拉机</p> <p id="dt_5">05号拖拉机</p> <p id="dt_6">06号拖拉机</p> <p id="dt_7">07号拖拉机</p> <p id="dt_8">08号拖拉机</p> <p id="dt_9">09号拖拉机</p> <p id="dt_10">10号拖拉机</p> <p id="dt_11">11号拖拉机</p> </div> <div id="mbDIV" style="display: none;"></div> <div id="loginDIV" style="top: 200px;left: 300px;display: none;"> <div id="loginTopDIV">Move</div> <p style="text-align: center;">登陆内容在这里哦</p> <form action="#" method="get" style="text-align: center