返回信息流
这是一条镜像帖。来源:北邮人论坛 / www-technology / #11544同步于 2010/11/18
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖
【请教】百度空间登录窗口的弹出层是怎么获取我的用户名thtyhus
thtyhust
2010/11/18镜像同步10 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
那有没有办法把背景页面上的值传给弹出层?
比如页面上有一组radio,
选中的其中一个,然后提交给弹出层,弹出层能获取这个radio的value么?
【 在 Anchor 的大作中提到: 】
: 浏览器存的吧
: 【 在 thtyhust (大猴子) 的大作中提到: 】
: : [upload=1][/upload]
: ...................
【 在 thtyhust 的大作中提到: 】
: 那有没有办法把背景页面上的值传给弹出层?
: 比如页面上有一组radio,
: 选中的其中一个,然后提交给弹出层,弹出层能获取这个radio的value么?
弹出层只是看起来是弹出的罢了,实际上还是写在背景页面上的。。。
【 在 thtyhust 的大作中提到: 】
: [upload=1][/upload]
: --
弹出层实际上是存在页面的,不过用CSS控制让它平时不显示,你点击某个按钮后,DOM获得你这个弹出层,然后在修改它的CSS中的display 属性,让它显示即可。
嗯
我现在的问题是 背景页面上有个按钮 一点击就触发了弹出层。
但是弹出层要先处理这个点击动作提交的表单,弹出再提交自己的表单。
比如下面这个图,我先选择一个文件夹(radio),然后点击重命名文件夹,触发弹出层。但是触发之前得先验证有没有选择radio(也就是表单验证)。然后还要在弹出层中把旧文件夹名和新文件夹名都提交给后台php,这相当于又提交了一次表单,而且用到了上次提交的数据。
有点乱~有没有啥好办法啊?
【 在 wangjianzhou 的大作中提到: 】
: :
: : --
: 弹出层实际上是存在页面的,不过用CSS控制让它平时不显示,你点击某个按钮后,DOM获得你这个弹出层,然后在修改它的CSS中的display 属性,让它显示即可。
: ...................
[upload=1][/upload]
【 在 thtyhust 的大作中提到: 】
: 嗯
: 我现在的问题是 背景页面上有个按钮 一点击就触发了弹出层。
: 但是弹出层要先处理这个点击动作提交的表单,弹出再提交自己的表单。
: ...................
1、验证radio是否选择,服务器端和js客户端都行,很简单。
2、表单提交验证,你可以让您PHP提交函数返回一个bool类型的值,若返回值为真,
直接PHP打印那个弹出层的HTML标签,这个DIV标签里的数据是取自你提交的数据,记得这个DIV的css绝对定位,以及将display属性设为:block
不是很明白啊。。。。晕乎了
我用的是从网上荡的LightBox弹出层。我是想让下面代码里主窗口里选中的radio值再弹出层提交给后台时一起提交。
比如我要删除一个文件夹,在主页面选中一个文件夹,然后点击按钮弹出弹出层,确认下,提交给后台php,这个php得知道选的是哪个文件夹。可是经过弹出层提交表单的时候无法获得主页面选中的radio值(也就是想要删除的那个文件夹)。
//弹出层css
<style type="text/css" media="screen">
body,p,div,ul,ol{padding:0;margin:0;border:0;}
body{height:100%;font-size:12px;}
.bgLayer{ background:#000; opacity:0.5; filter:alpha(opacity=50);z-index:10001;position:absolute;left:0;top:0;}
.boxLayer{ background:#fff; border:4px solid #ccc; overflow:hidden; zoom:1; z-index:10002; position:absolute;padding:8px;}
.boxLayer p{padding:5px 0;text-align:center;}
.alldenglu{
width:260px;}
.denglu {
font-size: 14px;
margin-bottom:6px;
color: #999999;
}
</style>
<script type="text/javascript">
//弹出层
function LightBox(boxWidth,boxHeight,boxContent)
{
this.boxWidth=boxWidth;
this.boxHeight=boxHeight;
this.boxContent=boxContent;
var bgLayer,boxLayer;
var documentHtml=document.documentElement;
this.createBgLayer=function()
{
bgLayer = document.createElement("div");
with (bgLayer)
{
className="bgLayer";
style.width=documentHtml.scrollWidth+"px";
style.height=documentHtml.scrollHeight+"px";
style.display="none";
}
document.body.insertBefore(bgLayer,document.body.firstChild);
};
this.createBox=function(){
boxLayer = document.createElement("div");
with (boxLayer)
{
className = "boxLayer";
style.width=this.boxWidth + "px";
style.height = this.boxHeight +"px";
style.display="none";
};
document.body.insertBefore(boxLayer,document.body.firstChild);
};
this.init= function()
{
this.createBgLayer();
this.createBox();
}
// if IE 6.0
function hideShowSelect(obj)
{
if (window.navigator.userAgent.indexOf("MSIE 6.0") > 0)
{
var selectDom = document.getElementsByTagName("select");
for (var i = 0; i < selectDom.length ; i++)
{
if (obj)
selectDom[i].style.display="none";
else
selectDom[i].style.display="";
}
}
};
this.show = function()
{
hideShowSelect(true);
boxLayer.innerHTML=this.boxContent;
bgLayer.style.display = "block";
boxLayer.style.display = "block";
boxLayer.style.left = documentHtml.offsetWidth /2 - boxLayer.offsetWidth/2 +"px";
boxLayer.style.top = documentHtml.scrollTop + documentHtml.clientHeight/2 - this.boxHeight/2 -30 + "px";
}
this.hide = function()
{
hideShowSelect(false);
bgLayer.style.display = "none";
boxLayer.style.display = "none";
}
}
//]]>
</script>
主窗口...html代码
//主窗口的表单
<form name="Folder" method="post" action="">
<input type="button" value="删除文件夹" onclick="loadBoxDel.show()"/>
<input type="radio" name="radiogroup" value="aaa";?> />
<input type="radio" name="radiogroup" value="bbb";?> />
<input type="radio" name="radiogroup" value="ccc";?> />
...html代码
</from>
<script type="text/javascript">
//调用方法
loadBoxDel.init();
//下面是弹出层的html,这里有最终要提交的表单
loadBoxDel.boxContent='<div class="alldenglu"><form action="folder_delete.php" method="post" enctype="multipart/form-data" name="indexForm"><div class="wenji"><font size="4" color="red"face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">???确定删除该文件夹?</font></div><br><br>
<div align="center" class="denglu"><input type="submit" name="delFolderSure" id="button" value="确定" onclick="return process("del")" />?<input type="button" value="取消" onclick="loadBoxDel.hide()" /></div></form></div>';
</script>