用DIV模拟弹出窗口,单击该层的SUBMIT按钮后,如何在关闭该DIV时刷新原页面?如图示:单击“打开层”后,弹出了DIV窗口(就是“标题”窗口),现在单击该层的“确定”按钮,如何在关闭DIV的同时刷新INDEX.HTML页面?谢谢!原代码:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>index</title>
<style>
.divtitle{
width: 200px;
height: 18px;
background-image: url('/imgs/2.jpg');
font-size: small;
font-weight: bold;
}
.closez{
cursor: pointer;
padding-left:110px;
}
.divcontext{
font-size: smaller;
border:1px solid red;
width: 200px;
height: 100px;
background-color: white;
}
.divbutton{
padding-left: 150px;
}
</style>
<script>
/* 动态创建背景层; */
function _ungroupay() {
var node = document.getElementById('sysbackgroupdis');
if (!node) {
node = document.createElement('div');
node.setAttribute('id', 'sysbackgroupdis');
node.style.visibility = 'hidden';
node.style.height = document.body.clientHeight + 'px';
node.style.width = document.body.clientWidth + 'px';
node.style.background = '#999';
node.style.opacity = '0.5';
node.style.filter = 'alpha(opacity=60)';
node.style.position = 'absolute';
node.style.top = '-9999px';
document.body.appendChild(node);
}
node.style.top = '0px';
node.style.left = '0px';
node.style.visibility = 'visible';
node.style.zIndex = 1;
}
/*页面显示类容*/
_systemplate = "<div align=\"center\" class=\"maincontext\" id=\"maincontext\">"+
"<div id=\"divtitle\" class=\"divtitle\">标题<a class=\"closez\" onclick=\"javascript:logoutdisp();\">关闭</a></div>"+
"<div id=\"divcontext\" class=\"divcontext\">"+
"<input type=\"button\" value=\"确定\" onclick=\"javascript:alert('提交');\"><p>填入其他代码</div>< /div>";
/* 创建调度函数 */
function calldisp() {
_ungroupay();
var node = document.getElementById('onbackground');
if (!node) {
node = document.createElement('div');
node.setAttribute('id', 'onbackground');
node.style.visibility = 'hidden';
node.style.top = '-9999px';
node.style.position = 'absolute';
node.style.border = '1px';
node.style.borderColor = 'black';
node.style.borderStyle = 'solid';
node.innerHTML = document.getElementById('maincontext').innerHTML;
document.body.appendChild(node);
}
node.style.top = Math.floor(document.body.scrollTop+(document.body.clientHeight-node.offsetHeight)/2)+'px';
node.style.left = Math.floor(document.body.scrollLeft+(document.body.clientWidth-node.offsetWidth)/2)+'px';
node.style.visibility='visible';
node.style.zIndex = 999;
}
/*退出层*/
function logoutdisp() {
var layerNode = document.getElementById("onbackground");
var underLayerNode = document.getElementById("sysbackgroupdis");
if (layerNode) {
layerNode.style.visibility="hidden";
layerNode.style.top = "-9999px";
}
if (underLayerNode) {
underLayerNode.style.visibility="hidden";
underLayerNode.style.top = "-9999px";
}
}
</script>
</head>
<body>
<div id="main" align="center"> <input type="button" value="打开层" onclick="javascript:calldisp();">
</div>
<div style="display: none;">
<div align="center" class="maincontext" id="maincontext">
<div id="divtitle" class="divtitle">标题<a class="closez" onclick="javascript:logoutdisp();">关闭</a></div>
<div id="divcontext" class="divcontext"><!--填写你需要的代码 start-->
<p>填入代码</p>
<div>输入:<input type="text"/></div> <!--填写你需要的代码 end-->
<div class="divbutton">
<input id="button" class="button" type="button" value="确定" onclick="javascript:logoutdisp();">
</div>
</div>
</div>
</div>
</body>
</html>
<html>
<head>
<title>index</title>
<style>
.divtitle{
width: 200px;
height: 18px;
background-image: url('/imgs/2.jpg');
font-size: small;
font-weight: bold;
}
.closez{
cursor: pointer;
padding-left:110px;
}
.divcontext{
font-size: smaller;
border:1px solid red;
width: 200px;
height: 100px;
background-color: white;
}
.divbutton{
padding-left: 150px;
}
</style>
<script>
/* 动态创建背景层; */
function _ungroupay() {
var node = document.getElementById('sysbackgroupdis');
if (!node) {
node = document.createElement('div');
node.setAttribute('id', 'sysbackgroupdis');
node.style.visibility = 'hidden';
node.style.height = document.body.clientHeight + 'px';
node.style.width = document.body.clientWidth + 'px';
node.style.background = '#999';
node.style.opacity = '0.5';
node.style.filter = 'alpha(opacity=60)';
node.style.position = 'absolute';
node.style.top = '-9999px';
document.body.appendChild(node);
}
node.style.top = '0px';
node.style.left = '0px';
node.style.visibility = 'visible';
node.style.zIndex = 1;
}
/*页面显示类容*/
_systemplate = "<div align=\"center\" class=\"maincontext\" id=\"maincontext\">"+
"<div id=\"divtitle\" class=\"divtitle\">标题<a class=\"closez\" onclick=\"javascript:logoutdisp();\">关闭</a></div>"+
"<div id=\"divcontext\" class=\"divcontext\">"+
"<input type=\"button\" value=\"确定\" onclick=\"javascript:alert('提交');\"><p>填入其他代码</div>< /div>";
/* 创建调度函数 */
function calldisp() {
_ungroupay();
var node = document.getElementById('onbackground');
if (!node) {
node = document.createElement('div');
node.setAttribute('id', 'onbackground');
node.style.visibility = 'hidden';
node.style.top = '-9999px';
node.style.position = 'absolute';
node.style.border = '1px';
node.style.borderColor = 'black';
node.style.borderStyle = 'solid';
node.innerHTML = document.getElementById('maincontext').innerHTML;
document.body.appendChild(node);
}
node.style.top = Math.floor(document.body.scrollTop+(document.body.clientHeight-node.offsetHeight)/2)+'px';
node.style.left = Math.floor(document.body.scrollLeft+(document.body.clientWidth-node.offsetWidth)/2)+'px';
node.style.visibility='visible';
node.style.zIndex = 999;
}
/*退出层*/
function logoutdisp() {
var layerNode = document.getElementById("onbackground");
var underLayerNode = document.getElementById("sysbackgroupdis");
if (layerNode) {
layerNode.style.visibility="hidden";
layerNode.style.top = "-9999px";
}
if (underLayerNode) {
underLayerNode.style.visibility="hidden";
underLayerNode.style.top = "-9999px";
}
}
</script>
</head>
<body>
<div id="main" align="center"> <input type="button" value="打开层" onclick="javascript:calldisp();">
</div>
<div style="display: none;">
<div align="center" class="maincontext" id="maincontext">
<div id="divtitle" class="divtitle">标题<a class="closez" onclick="javascript:logoutdisp();">关闭</a></div>
<div id="divcontext" class="divcontext"><!--填写你需要的代码 start-->
<p>填入代码</p>
<div>输入:<input type="text"/></div> <!--填写你需要的代码 end-->
<div class="divbutton">
<input id="button" class="button" type="button" value="确定" onclick="javascript:logoutdisp();">
</div>
</div>
</div>
</div>
</body>
</html>
似乎起到作用,我尝试了opener.location.reload等等,和self.location=self.location的效果一样:整个页面变成空白了。
那要看你的index.htm的内容而定了,一片空白的话应该是哪里出了问题