请教,这种弹出式对话框效果是怎样弄的?(图) 你看到的那个对话框其实是个DIV.在那个对话框下面一层还是一个DIV,占满浏鉴器整个客户区,有透明度 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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> <title>Untitled Page</title> <script type="text/javascript"> window.onload = function() { var modalLayer = document.createElement('DIV'); modalLayer.style.position = 'absolute'; modalLayer.style.left = '0px'; modalLayer.style.top = '0px'; modalLayer.style.width = '100%'; modalLayer.style.height = document.body.clientHeight; modalLayer.style.backgroundColor = 'red'; modalLayer.style.filter = "alpha(opacity=80)"; var dlg = document.createElement("DIV"); dlg.style.left = '100px'; dlg.style.top = '100px'; dlg.style.width = '100px'; dlg.style.height = '100px'; dlg.style.position = 'absolute'; dlg.innerHTML = 'Dialog'; document.body.appendChild(modalLayer); document.body.appendChild(dlg); } </script></head><body> <div style="height:800px"> lsfjslj<br /> sljfkl<br /> <hr /> </div></body></html> 请教怎样把表格加入到第二个层上呢,dlg.innerHTML = 'Dialog';只能示文本吗?我试了,不能加html代码呢? <input type="button" name="aa" value="aa" onclick="showDiv();"/>ABCDE<script>function showDiv(){var div = document.createElement("div");div.style.top = 300;div.style.left = 300;div.style.backgroundColor = "red";div.style.display = "inline";div.innerHTML = "hello, world.";document.body.appendChild(div);}</script>我测试了一下,这段代码,生成一个层后怎样关闭呢? 关闭你就把这个层的display属性设置为none <input type="button" name="aa" value="aa" onclick="showDiv();"/>ABCDE<script>function showDiv(){var div = document.createElement("div");div.id="hk2009";div.style.top = 300;div.style.left = 300;div.style.backgroundColor = "red";div.style.display = "inline";div.innerHTML = "hello, world.<a onclick='document.all."+ div.id +".style.display=\"none\"'>sss</a>";document.body.appendChild(div);}</script> 上面的sss换成关闭<input type="button" name="aa" value="aa" onclick="showDiv();"/>ABCDE<script>function showDiv(){var div = document.createElement("div");div.id="hk2009";div.style.top = 300;div.style.left = 300;div.style.backgroundColor = "red";div.style.display = "inline";div.innerHTML = "hello, world.<a onclick='document.all."+ div.id +".style.display=\"none\"'>[关闭]</a>";document.body.appendChild(div);}</script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="gb2312" ><script>function _debug(msg){alert(msg); document.getElementById('search').focus();}</script><head onload="javascript:_debug(aa);"> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <meta name="author" content="Smiling Dolphin" /> <meta name="keywords" content="design, css, cascading, style, sheets, xhtml, graphic design, w3c, web standards, visual, display, java, javascript, c++, php, jsp, asp, py, pl" /> <meta name="description" content="my favorites language." /> <meta name="robots" content="all" /> <title>Dolphin Document</title></head><body><input type="button" value="显示Alert" onclick="alert('我改写了Alert显示的样式')" /><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><input name = "search" id="search" type="text" /><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><p>abc</p><script language="javascript" type="text/javascript">window.alert = function(txt){ //document.write(txt); var shield = document.createElement("DIV"); shield.style.position = "absolute"; shield.style.left = "0px";// shield.id = "shield"; shield.style.top = "0px"; shield.style.width = "100%"; shield.style.height = document.body.clientHeight+"px"; shield.style.background = "#333"; shield.style.textAlign = "center";// shield.style.lineHeight = document.body.clientHeight+"px"; shield.style.zIndex = "1"; shield.style.filter = "alpha(opacity=0)"; var alertFram = document.createElement("DIV"); alertFram.style.position = "absolute"; alertFram.style.left = "50%"; alertFram.style.top = "50%"; alertFram.style.marginLeft = "-225px"; alertFram.style.marginTop = "-75px"; alertFram.style.width = "450px"; alertFram.style.height = "150px"; alertFram.style.background = "#ccc"; alertFram.style.textAlign = "center"; alertFram.style.lineHeight = "150px"; alertFram.style.zIndex = "2"; strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n"; strHtml += " <li style=\"background:#DD828D;text-align:left;padding-left:20px;font-weight:bold;height:25px;line-height:25px;border:1px solid #F9CADE;\">[系统提示]</li>\n"; strHtml += " <li style=\"background:#fff;text-align:center;font-weight:bold;height:120px;line-height:120px;border-left:1px solid #F9CADE;border-right:1px solid #F9CADE;\">"+txt+"</li>\n"; strHtml += " <li style=\"background:#FDEEF4;text-align:center;font-weight:bold;height:25px;line-height:25px; border:1px solid #F9CADE;\"><input type=\"button\" value=\"确 定\" onclick=\"doOk()\" /></li>\n"; strHtml += "</ul>\n"; alertFram.innerHTML = strHtml; document.body.appendChild(alertFram); document.body.appendChild(shield); var c = 0; this.doAlpha = function(){ if (c++ > 10){clearInterval(ad);return 0;} shield.style.filter = "alpha(opacity="+c+");"; } var ad = setInterval("doAlpha()",20); this.doOk = function(){ alertFram.style.display = "none"; shield.style.display = "none"; }}</script></body></html> google lightbox 有你想要的结果 谢谢大家!特别感谢 Yaba_lx Yaba_lx 我的显示器1280*1024的后面的灰色背景右边有20PX的地方不能到边呢?我调了一下代码,也不行 我想把 +txt+ 处换成表单的形式,但是天上代码后不能显示了呢??<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\"><table width=\"350\" border=\"0\" cellspacing=\"0\" cellpadding=\"6\"> <tr> <td width=\"82\"><div align=\"center\">您的姓名:</div></td>\n"; strHtml += " <td width=\"244\"><div align=\"left\"> <label> <input name=\"textfield\" type=\"text\" size=\"25\" /> \n"; strHtml += " *</label> </div></td> </tr> <tr> <td><div align=\"center\">您的Email:</div></td>\n"; strHtml += " <td><div align=\"left\"> <input name=\"textfield2\" type=\"text\" size=\"25\" />\n"; strHtml += " *</div></td> </tr>\n"; strHtml += " <tr> <td><div align=\"center\">说明:</div></td>\n"; strHtml += " <td><div align=\"left\"> <label> <textarea name=\"textarea\" rows=\"6\"></textarea> </label>\n"; strHtml += " *</div></td> </tr>\n"; </table></form> ie中如何让一个disable的按钮不再获得焦点,最好能够让他下一个按钮获得焦点,help! ─── 有一个超酷的脚本,希望大家研究研究如何搞定她 ─── 一个jquery里面的正则表达式没太看明白 求一js 请问 ,如何将全角状态下的数字替换为英文状态下的数字,在线等待中... 得到框架的location.... 怎么去掉变量中的换行符和空格符?(不同别人问的) 怎么关闭window.showdialog弹出的窗口 javascript的程序运行控制问题 闷:程序员为什么跳槽?(不好意思,非技术区人少) 如何查找某字符串是否是一个数组的值之一? 删除select选中项的问题
<html xmlns="http://www.w3.org/1999/xhtml" ><head>
<title>Untitled Page</title>
<script type="text/javascript">
window.onload = function() {
var modalLayer = document.createElement('DIV');
modalLayer.style.position = 'absolute';
modalLayer.style.left = '0px';
modalLayer.style.top = '0px';
modalLayer.style.width = '100%';
modalLayer.style.height = document.body.clientHeight;
modalLayer.style.backgroundColor = 'red';
modalLayer.style.filter = "alpha(opacity=80)";
var dlg = document.createElement("DIV");
dlg.style.left = '100px';
dlg.style.top = '100px';
dlg.style.width = '100px';
dlg.style.height = '100px';
dlg.style.position = 'absolute';
dlg.innerHTML = 'Dialog';
document.body.appendChild(modalLayer);
document.body.appendChild(dlg);
}
</script>
</head>
<body>
<div style="height:800px">
lsfjslj<br />
sljfkl<br />
<hr />
</div>
</body>
</html>
dlg.innerHTML = 'Dialog';只能示文本吗?我试了,不能加html代码呢?
ABCDE<script>
function showDiv(){
var div = document.createElement("div");
div.style.top = 300;
div.style.left = 300;
div.style.backgroundColor = "red";
div.style.display = "inline";
div.innerHTML = "hello, world.";
document.body.appendChild(div);
}
</script>我测试了一下,这段代码,生成一个层后怎样关闭呢?
ABCDE<script>
function showDiv(){
var div = document.createElement("div");
div.id="hk2009";
div.style.top = 300;
div.style.left = 300;
div.style.backgroundColor = "red";
div.style.display = "inline";
div.innerHTML = "hello, world.<a onclick='document.all."+ div.id +".style.display=\"none\"'>sss</a>";
document.body.appendChild(div);
}
</script>
<input type="button" name="aa" value="aa" onclick="showDiv();"/>
ABCDE<script>
function showDiv(){
var div = document.createElement("div");
div.id="hk2009";
div.style.top = 300;
div.style.left = 300;
div.style.backgroundColor = "red";
div.style.display = "inline";
div.innerHTML = "hello, world.<a onclick='document.all."+ div.id +".style.display=\"none\"'>[关闭]</a>";
document.body.appendChild(div);
}
</script>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="gb2312" >
<script>
function _debug(msg)
{
alert(msg);
document.getElementById('search').focus();
}
</script><head onload="javascript:_debug(aa);">
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta name="author" content="Smiling Dolphin" />
<meta name="keywords" content="design, css, cascading, style, sheets, xhtml, graphic design, w3c, web standards, visual, display, java, javascript, c++, php, jsp, asp, py, pl" />
<meta name="description" content="my favorites language." />
<meta name="robots" content="all" />
<title>Dolphin Document</title>
</head>
<body>
<input type="button" value="显示Alert" onclick="alert('我改写了Alert显示的样式')" />
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<input name = "search" id="search" type="text" />
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<p>abc</p>
<script language="javascript" type="text/javascript">
window.alert = function(txt)
{
//document.write(txt);
var shield = document.createElement("DIV");
shield.style.position = "absolute";
shield.style.left = "0px";
// shield.id = "shield";
shield.style.top = "0px";
shield.style.width = "100%";
shield.style.height = document.body.clientHeight+"px";
shield.style.background = "#333";
shield.style.textAlign = "center";
// shield.style.lineHeight = document.body.clientHeight+"px";
shield.style.zIndex = "1";
shield.style.filter = "alpha(opacity=0)";
var alertFram = document.createElement("DIV");
alertFram.style.position = "absolute";
alertFram.style.left = "50%";
alertFram.style.top = "50%";
alertFram.style.marginLeft = "-225px";
alertFram.style.marginTop = "-75px";
alertFram.style.width = "450px";
alertFram.style.height = "150px";
alertFram.style.background = "#ccc";
alertFram.style.textAlign = "center";
alertFram.style.lineHeight = "150px";
alertFram.style.zIndex = "2";
strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
strHtml += " <li style=\"background:#DD828D;text-align:left;padding-left:20px;font-weight:bold;height:25px;line-height:25px;border:1px solid #F9CADE;\">[系统提示]</li>\n";
strHtml += " <li style=\"background:#fff;text-align:center;font-weight:bold;height:120px;line-height:120px;border-left:1px solid #F9CADE;border-right:1px solid #F9CADE;\">"+txt+"</li>\n";
strHtml += " <li style=\"background:#FDEEF4;text-align:center;font-weight:bold;height:25px;line-height:25px; border:1px solid #F9CADE;\"><input type=\"button\" value=\"确 定\" onclick=\"doOk()\" /></li>\n";
strHtml += "</ul>\n";
alertFram.innerHTML = strHtml;
document.body.appendChild(alertFram);
document.body.appendChild(shield);
var c = 0;
this.doAlpha = function(){
if (c++ > 10){clearInterval(ad);return 0;}
shield.style.filter = "alpha(opacity="+c+");";
}
var ad = setInterval("doAlpha()",20);
this.doOk = function(){
alertFram.style.display = "none";
shield.style.display = "none";
}
}
</script></body>
</html>
<table width=\"350\" border=\"0\" cellspacing=\"0\" cellpadding=\"6\">
<tr>
<td width=\"82\"><div align=\"center\">您的姓名:</div></td>\n";
strHtml += " <td width=\"244\"><div align=\"left\">
<label>
<input name=\"textfield\" type=\"text\" size=\"25\" /> \n";
strHtml += " *</label>
</div></td>
</tr>
<tr>
<td><div align=\"center\">您的Email:</div></td>\n";
strHtml += " <td><div align=\"left\">
<input name=\"textfield2\" type=\"text\" size=\"25\" />\n";
strHtml += " *</div></td>
</tr>\n";
strHtml += " <tr>
<td><div align=\"center\">说明:</div></td>\n";
strHtml += " <td><div align=\"left\">
<label>
<textarea name=\"textarea\" rows=\"6\"></textarea>
</label>\n";
strHtml += " *</div></td>
</tr>\n";
</table>
</form>