子窗口关闭,父窗口如何刷新

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了子窗口关闭,父窗口如何刷新相关的知识,希望对你有一定的参考价值。

参考技术A ;
form.submit();
window.close();

同时
body
onUnload=
javascrip:reshow();
function
reshow()
window.opener.location.reload();

求达人解决
谢谢!
------解决方案--------------------------------------------------------
1、打开子窗口
2、在子窗口中对父窗口的变量进行复制
3、关闭子窗口
--这是父窗口中,点击“添加人员”弹出子窗口--
JScript
code
td
class=
tdConOne
input
type=
text
id=
number
name=
number
class=
input
disabled=
disabled
/
font
color=
red
*
/font
nbsp;
nbsp;
input
type=
button
value=
添加人员
class=
button
onclick=
openwin('*.do',700,550)
/
/td
//这个函数是打开一个新的窗口
function
openwin(url,wwidth,wheight)

var
x=(screen.Width-wwidth)/2;
var
y=(screen.Height-wheight)/2;
window.open(url,
'',
'toolbars=0,
scrollbars=0,
location=0,
statusbars=0,
menubars=0,
resizable=0,
width='+wwidth+',
height='+wheight+',
left='+x+',
top='+y);

------解决方案--------------------------------------------------------
2、在子窗口中对父窗口的变量进行赋值
------解决方案--------------------------------------------------------
$(
#addForm
).ajaxSubmit(
beforeSubmit:function
()

$(
#saveBtn
).attr(
disabled
,true);
,
success:function
(data)

if(data
==
ok
)

alert(
增加成功
);
flushParentPage();
window.close();

if(data
==
error
)

alert(
增加失败
);

$(
#saveBtn
).attr(
disabled
,false);
,
complete:function
()

$(
#saveBtn
).attr(
disabled
,false);
,
error
:
function()

$(
#saveBtn
).attr(
disabled
,false);
alert(
请求错误
);

);

js
里面写个这个,我也看不太懂
,反正就这么写的
function
flushParentPage()

var
pageNo
=
1;
try

pageNo
=
window.opener.document.getElementById(
pageNo
).value;
var
url
=
window.opener.document.getElementById(
url
).value;
if(url.indexOf(
?
)
!=
-1)

url
+=
pageNo=
+
pageNo;

else

url
+=
?pageNo=
+
pageNo;

window.opener.document.queryForm.setAttribute(
action
,
url);

catch
(err)


window.opener.document.queryForm.submit();

function
closeOpenPage()

window.close();

------解决方案--------------------------------------------------------
不是有parent

------解决方案--------------------------------------------------------
父窗口中的js
片段
//xxAction
是你要打开页面前的逻辑处理,再在action
的配置文件中跳转到你要打开的jsp
页面
open(
xxAction
,
,
menubar=no,toolbar=no,status=no,width=500,heigth=300
);
在子窗口添加一个确定按钮触发一个事件,在js
代码中最后加上下面代码
//opener
表示的是父窗口
window.opener.document.getElementById(
xxx
).value
=
mgrno;
window.close();
------解决方案--------------------------------------------------------
上面的xxx
是你父窗口中要赋的值。mgrno
是子窗口选中的值。我忘记改过来了
------解决方案--------------------------------------------------------

jsp点击右上角的X关闭子窗口刷新父窗口该如何实现呢?

参考技术A 你把刷新的功能,写到关闭前面,也就是先刷新,在关闭 参考技术B 父页面js:
function btnAdd_onclick()
window.open("xxx.jsp", "","height=600, width=650, top=100, left=200,z-look=yes,toolbar=yes, menubar=no, scrollbars=yes, resizable=yes ,alwaysRaised=yes,
location=no, status=yes" );

function refresh()

this.location = this.location;


子页面JS:

function close()

window.opener.refresh();//重点就在这里刷新
window.focus();
window.opener=null;
window.close();

重点是在父页面写一个刷新方法,在子页面通过window.opener.父页面中刷新的方法来实现这个功能。本回答被提问者采纳

以上是关于子窗口关闭,父窗口如何刷新的主要内容,如果未能解决你的问题,请参考以下文章

怎么实现父窗口打开子窗口,子窗口关闭后自动刷新父窗口?

父窗口刷新的问题!

C#里面,子窗口关闭以后,刷新一个父窗口的控件的属性,怎么办

QT5怎样设置父窗口刷新时,不刷新子窗口?

showModalDialog/showModelessDialog实例,父窗口向子窗口传递值,子窗口设置父窗口的值,子窗口关闭的时候返回值到父窗口.关闭刷新父窗口

关闭jQUERY中的弹出窗口后如何刷新父页面? [复制]