请教各位高手关闭弹出窗口时刷新父窗口的问题 你open页面的时候,显示open的小页面,关闭时,在open的小页面上放一个返回按键,使用window.open是不可能去刷新之前的页面的.因为它们之间没有关系可言.建议你使用iframe+div而不用window.open(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 返回放一个按钮,刷新使用parent.location.href = parent.location.href 或者parent.location.reload(); 不知道你的父页面有没有转页,下面有个例子//a.html<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>新建网页 1</title><script>function open_win(){div1.innerHTML="已经操作了";//父页面没有转页window.open("b.html","","width:300px;height:200px");//document.write("已经操作了");//父页面已经转页,即浏览器上方的"后退"按钮有效}</script></head><body><div id=div1>刚加载</div><input type=button onclick=open_win() value="打开窗口"></body></html>//b.html<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>b</title><script>function return_back(){opener.history.go();//没有转页//opener.location.reload();//没有转页//opener.history.back();//已经转页//opener.history.go(-1);//已经转页window.close();}</script></head><body><input type=button value="关闭" onclick=return_back()></body></html> 子窗口的<body>加上属性onunload="window.opener.location.replace(opener.location);" 用这种方法 就是不用在页面单独做按钮,直接点击右上的关闭按钮 然后刷新function window.onbeforeunload(){ if(event.clientX>360&&event.clientY<0||event.altKey) { event.returnValue="OK?"; opener.location.reload(); }}LZ是想要这种效果么? lihui_shine(浪尖賞花)告诉的方法我已经试过了,可以关闭子窗口,但是父窗口没有刷新,请各位帮我看看lihui_shine(浪尖賞花)写的代码中有什么地方需要改动,谢谢 我不是不想用s_liangchao1s(求学) 的方法,是因为我的子窗口中需要按钮进行提交,不能够直接直接点击右上的关闭按钮,所以还是请各位高手帮帮忙,看看需要修改什么地方才能使父窗口刷新。谢谢function return_back(){opener.history.go();//没有转页//opener.location.reload();//没有转页//opener.history.back();//已经转页//opener.history.go(-1);//已经转页window.close();} 用window.location.herf="父页面";看行不? opener.location.herf=opener.location.herf; a.htm:<!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>无标题页</title> <script> function refresh(str) { document.getElementById("txt").value=str; } </script></head><body> <input id="txt" type="text" /> <input id="Btn" type="button" value="打开子页面" onclick="window.open('b.htm')" /></body></html>b.htm:<!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>无标题页</title> <script> function passValue() { var pass=document.getElementById("txt2").value; window.opener.refresh(pass); window.focus(); window.opener=null; window.close(); } </script></head><body><input type="text" id="txt2" value="这是我传给你的,你要收好了" /><input type="button" value="传值并刷新" onclick="passValue()" /></body></html>这个就是你要的效果 dom相关的问题 邮件里发html代码问题 帮忙看看这个javascript效果是怎么做出来的?效果叫什么名字????????????? frames的问题 谁能发一个JS版MD5函数,网上找的加密中文时就和VB版结果不一样:( 关于include的问题 如何屏蔽弹出式窗口的最大化功能? 求教;如何在当前网页获取前一个网页的地址? 网页设计问题,我的网页是口字型。请进来看看!谢谢。 真的不能再简单的问题了,我都不好意思问了! indexOf()的用法?? ext-1.1.1--Hello World 例子问题
刷新使用parent.location.href = parent.location.href
或者parent.location.reload();
//a.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script>
function open_win(){
div1.innerHTML="已经操作了";//父页面没有转页
window.open("b.html","","width:300px;height:200px");
//document.write("已经操作了");//父页面已经转页,即浏览器上方的"后退"按钮有效
}
</script>
</head>
<body>
<div id=div1>刚加载</div>
<input type=button onclick=open_win() value="打开窗口">
</body>
</html>//b.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>b</title>
<script>
function return_back(){
opener.history.go();//没有转页
//opener.location.reload();//没有转页
//opener.history.back();//已经转页
//opener.history.go(-1);//已经转页
window.close();
}
</script>
</head>
<body>
<input type=button value="关闭" onclick=return_back()>
</body>
</html>
function window.onbeforeunload()
{
if(event.clientX>360&&event.clientY<0||event.altKey)
{
event.returnValue="OK?";
opener.location.reload();
}
}LZ是想要这种效果么?
function return_back(){
opener.history.go();//没有转页
//opener.location.reload();//没有转页
//opener.history.back();//已经转页
//opener.history.go(-1);//已经转页
window.close();
}
看行不?
<!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>无标题页</title>
<script>
function refresh(str)
{
document.getElementById("txt").value=str;
}
</script>
</head>
<body>
<input id="txt" type="text" />
<input id="Btn" type="button" value="打开子页面" onclick="window.open('b.htm')" /></body>
</html>b.htm:
<!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>无标题页</title>
<script>
function passValue()
{
var pass=document.getElementById("txt2").value;
window.opener.refresh(pass);
window.focus();
window.opener=null;
window.close();
}
</script>
</head>
<body>
<input type="text" id="txt2" value="这是我传给你的,你要收好了" />
<input type="button" value="传值并刷新" onclick="passValue()" />
</body>
</html>这个就是你要的效果