风之石 请 如何有一个像样弹出层啊!!!!! 本帖最后由 plglenn28 于 2009-12-17 09:14:13 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 [code=HTML<html> <head> <title>2008年命运</title> <meta http-equiv="Content-Language" content="gb2312" /> </head> <body oncontextmenu="return false"> <div style="z-index: 100; left: 315px; width: 25%; position: absolute; top: 200px"> <input type="button" value="2008年命运" onclick="sAlert('这是内容');" /> </div> <script type="text/javascript" language="javascript"> function sAlert(str){ var msgw,msgh,bordercolor; msgw=400;//提示窗口的宽度 msgh=200;//提示窗口的高度 titleheight=25 //提示窗口标题高度 bordercolor="#ffcccc";//提示窗口的边框颜色 titlecolor="#0909F7";//提示窗口的标题颜色 var sWidth,sHeight; sWidth=document.body.offsetWidth; sHeight=screen.height;//创建一个大的DIV---bgDiv 作为背景遮阴 var bgObj=document.createElement("div"); bgObj.setAttribute('id','bgDiv'); bgObj.style.position="absolute"; bgObj.style.top="0"; bgObj.style.background="#777"; bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; bgObj.style.opacity="0.6"; bgObj.style.left="0"; bgObj.style.width=sWidth + "px"; bgObj.style.height=sHeight + "px"; bgObj.style.zIndex = "10000"; document.body.appendChild(bgObj); //在bgDiv里面创建一个用于显示消息的msgDiv var msgObj=document.createElement("div") msgObj.setAttribute("id","msgDiv"); msgObj.setAttribute("align","center"); msgObj.style.background="#EEC591"; msgObj.style.border="1px solid " + bordercolor; msgObj.style.position = "absolute"; msgObj.style.left = "50%"; msgObj.style.top = "50%"; msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; msgObj.style.marginLeft = "-225px" ; msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; msgObj.style.width = msgw + "px"; msgObj.style.height =msgh + "px"; msgObj.style.textAlign = "center"; msgObj.style.lineHeight ="25px"; msgObj.style.border = "4px #ff0000 double"; msgObj.style.zIndex = "10001"; //用于显示消息头信息的 var title=document.createElement("h1"); title.setAttribute("id","msgTitle"); title.setAttribute("align","right"); title.style.margin="0"; title.style.padding="3px"; title.style.background="#FF4040"; title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; title.style.opacity="0.75"; title.style.border="1px solid " + bordercolor; title.style.height="18px"; title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; title.style.color="#17081A"; title.style.cursor="pointer"; title.innerHTML="点击=关闭"; title.onclick=function(){ document.body.removeChild(bgObj); document.getElementById("msgDiv").removeChild(title); document.body.removeChild(msgObj); } document.body.appendChild(msgObj); document.getElementById("msgDiv").appendChild(title); var txt=document.createElement("p"); txt.style.margin="1em 0" txt.setAttribute("id","msgTxt"); txt.innerHTML=str; document.getElementById("msgDiv").appendChild(txt); } </script> </body> </html>[/code] 直接复制就可看到效果<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>LIGHTBOX EXAMPLE</title> <style> .black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content { display: none; position: absolute; top: 25%; left: 25%; width: 25%; height: 25%; padding: 16px; border: 16px solid orange; background-color: white; z-index:1002; overflow: auto; } </style> <script type="text/javascript"> function showDiv() { document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'; } function getResult() { document.getElementById('light').style.display='none'; document.getElementById('fade').style.display='none'; document.getElementById('text1').value=document.getElementById('txt1').value; } </script></head> <body> <br><br><input type="text" value="" id="text1"><p><a href = "javascript:void(0)" onclick = "showDiv();">点击这里打开窗口</a></p> <br><br><div id="light" class="white_content"> <table> <tr> <td align="right">输入名称</td> <td width="78%"> <input id="txt1" type="text" /></td> </tr> <tr> <td></td> <td><input type="button" value="添加" onclick=""/> <input type="reset" value="重置" /></td> </tr> </table> <a href = "javascript:void(0)" style="position:absolute;top:0px;right:0px;" onclick = "getResult()">Close</a></div><div id="fade" class="black_overlay"></div> </body> </html> 用jQuery做:function lo(){ $("#work").load(url,type);} URL是你要弹出层的页面地址 work是自己创建的div id type是你往弹出层传数据,不要也行例:document.writeln("<div id='work' style='z-index:9999;display:none; width:1000px; height:249px; border: 0px solid red;position:absolute;top:expression((document.documentElement.clientHeight-this.offsetHeight)/3);left:expression((document.documentElement.clientWidth-this.offsetWidth)/2);'></div>");onclick="lo('husbandry_chicken.jsp',{'index':1,'img':'Chicken_3.png'); 不好意思,刚看到你这个帖子。请参考:<html><head><title>show popup layer</title><style type="text/css">html,body{height:100%;overflow:hidden;}</style></head><body><button onclick="showpopup('title here','content here ^_^');">show popup layer</button></body><script type="text/javascript" src="http://www.easyui.org.cn/easyui.js"></script><!--如果不需要拖拽,则不需要加载easydragdrop.js--><script type="text/javascript" src="http://www.easyui.org.cn/easydragdrop.js"></script><script type="text/javascript" src="http://www.easyui.org.cn/easylayer.js"></script><script type="text/javascript" src="http://www.easyui.org.cn/easymask.js"></script><script type="text/javascript" src="http://www.easyui.org.cn/easypopup.js"></script><script type="text/javascript">var dmask = new easyMask(null,'100%','100%',100,'#000',30,false);var dpopup = new easyPopup(null,'formsubmitpopup',null,'#0055EA','#fff',true,500,250,10010);var showpopup = function(stitle,scontent,fooclick,fooclose){ //easypopup属性及事件请参阅http://www.easyui.org.cn/easydraglayer.html dpopup.fixsize = true; dpopup.autofullsize = false; dpopup.setShadow(); if(fooclick&&fooclick.constructor==Function){dpopup.onclick = function(e){var d = easyUI.getTarget(e);fooclick(d,dpopup);};} dpopup.onopen = function(){dmask.open();}; dpopup.onclose = function(){dmask.close();if(fooclose&&fooclose.constructor==Function){fooclose();}}; dpopup.setTitle(stitle); dpopup.setContent(scontent); if(!dpopup.isopen){dpopup.open();}};</script></html> 一个滑动门效果在vs2010里报错 〓〓带滑动效果的菜单栏展开与收缩???〓〓 能用JS实现类似于CSDN的结帖给分的功能吗 javascript中toExponential()属性用法是什么 高分求动态生成div隐藏菜单的规范代码 对于三级类有什么好的方法来实现吗? 史上最牛逼聊天插件 window.showModalDialog()窗口如何全屏? 高手请进,table的拖动列头,交换位置 请问在javascript脚本中如何创建自己的对象,并为之设置属性和方法?(100分) 简单的checkbox验证问题,急,在线等。。。 急,如何动态添加事件
<html>
<head>
<title>2008年命运</title>
<meta http-equiv="Content-Language" content="gb2312" />
</head>
<body oncontextmenu="return false">
<div style="z-index: 100; left: 315px; width: 25%; position: absolute; top: 200px">
<input type="button" value="2008年命运" onclick="sAlert('这是内容');" />
</div>
<script type="text/javascript" language="javascript">
function sAlert(str){
var msgw,msgh,bordercolor;
msgw=400;//提示窗口的宽度
msgh=200;//提示窗口的高度
titleheight=25 //提示窗口标题高度
bordercolor="#ffcccc";//提示窗口的边框颜色
titlecolor="#0909F7";//提示窗口的标题颜色
var sWidth,sHeight;
sWidth=document.body.offsetWidth;
sHeight=screen.height;
//创建一个大的DIV---bgDiv 作为背景遮阴
var bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.style.background="#777";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
bgObj.style.height=sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
//在bgDiv里面创建一个用于显示消息的msgDiv
var msgObj=document.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="#EEC591";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "50%";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw + "px";
msgObj.style.height =msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight ="25px";
msgObj.style.border = "4px #ff0000 double";
msgObj.style.zIndex = "10001";
//用于显示消息头信息的
var title=document.createElement("h1");
title.setAttribute("id","msgTitle");
title.setAttribute("align","right");
title.style.margin="0";
title.style.padding="3px";
title.style.background="#FF4040";
title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
title.style.opacity="0.75";
title.style.border="1px solid " + bordercolor;
title.style.height="18px";
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
title.style.color="#17081A";
title.style.cursor="pointer";
title.innerHTML="点击=关闭";
title.onclick=function(){
document.body.removeChild(bgObj);
document.getElementById("msgDiv").removeChild(title);
document.body.removeChild(msgObj);
}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(title);
var txt=document.createElement("p");
txt.style.margin="1em 0"
txt.setAttribute("id","msgTxt");
txt.innerHTML=str;
document.getElementById("msgDiv").appendChild(txt);
}
</script>
</body>
</html>
[/code]
<html>
<head>
<title>LIGHTBOX EXAMPLE</title>
<style>
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 25%;
height: 25%;
padding: 16px;
border: 16px solid orange;
background-color: white;
z-index:1002;
overflow: auto;
}
</style> <script type="text/javascript">
function showDiv()
{
document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';
}
function getResult()
{
document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none';
document.getElementById('text1').value=document.getElementById('txt1').value;
}
</script>
</head>
<body>
<br>
<br>
<input type="text" value="" id="text1">
<p>
<a href = "javascript:void(0)" onclick = "showDiv();">点击这里打开窗口</a>
</p>
<br>
<br><div id="light" class="white_content">
<table>
<tr>
<td align="right">输入名称</td>
<td width="78%"> <input id="txt1" type="text" /></td>
</tr>
<tr>
<td></td>
<td><input type="button" value="添加" onclick=""/>
<input type="reset" value="重置" /></td>
</tr>
</table>
<a href = "javascript:void(0)" style="position:absolute;top:0px;right:0px;" onclick = "getResult()">Close</a>
</div>
<div id="fade" class="black_overlay"></div>
</body>
</html>
function lo(){
$("#work").load(url,type);
}
URL是你要弹出层的页面地址
work是自己创建的div id
type是你往弹出层传数据,不要也行
例:
document.writeln("<div id='work' style='z-index:9999;display:none; width:1000px; height:249px; border: 0px solid red;position:absolute;top:expression((document.documentElement.clientHeight-this.offsetHeight)/3);left:expression((document.documentElement.clientWidth-this.offsetWidth)/2);'></div>");onclick="lo('husbandry_chicken.jsp',{'index':1,'img':'Chicken_3.png');
<html>
<head>
<title>show popup layer</title>
<style type="text/css">
html,body{height:100%;overflow:hidden;}
</style>
</head>
<body>
<button onclick="showpopup('title here','content here ^_^');">show popup layer</button>
</body>
<script type="text/javascript" src="http://www.easyui.org.cn/easyui.js"></script>
<!--如果不需要拖拽,则不需要加载easydragdrop.js-->
<script type="text/javascript" src="http://www.easyui.org.cn/easydragdrop.js"></script>
<script type="text/javascript" src="http://www.easyui.org.cn/easylayer.js"></script>
<script type="text/javascript" src="http://www.easyui.org.cn/easymask.js"></script>
<script type="text/javascript" src="http://www.easyui.org.cn/easypopup.js"></script>
<script type="text/javascript">
var dmask = new easyMask(null,'100%','100%',100,'#000',30,false);
var dpopup = new easyPopup(null,'formsubmitpopup',null,'#0055EA','#fff',true,500,250,10010);
var showpopup = function(stitle,scontent,fooclick,fooclose){
//easypopup属性及事件请参阅http://www.easyui.org.cn/easydraglayer.html
dpopup.fixsize = true;
dpopup.autofullsize = false;
dpopup.setShadow();
if(fooclick&&fooclick.constructor==Function){dpopup.onclick = function(e){var d = easyUI.getTarget(e);fooclick(d,dpopup);};}
dpopup.onopen = function(){dmask.open();};
dpopup.onclose = function(){dmask.close();if(fooclose&&fooclose.constructor==Function){fooclose();}};
dpopup.setTitle(stitle);
dpopup.setContent(scontent);
if(!dpopup.isopen){dpopup.open();}
};
</script>
</html>