How to refresh the parent page and closing the child window using javascript when I click the button in parent page asp I am able to refresh the parent page but my child window is not closing. My C# Code is
string script = @"<script>
function RefreshParent()
{
window.close();
window.opener.location.reload();
}RefreshParent();
</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "ssr", script);
How to refresh the parent page and closing the child window using javascript when I click the button in parent page asp I am able to refresh the parent page but my child window is not closing. My C# Code is
string script = @"<script>
function RefreshParent()
{
window.close();
window.opener.location.reload();
}RefreshParent();
</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "ssr", script);
Share
Improve this question
edited Sep 12, 2012 at 6:38
lc.
117k21 gold badges161 silver badges188 bronze badges
asked Sep 12, 2012 at 6:35
LakkiLakki
652 silver badges6 bronze badges
1
- try to call reload() method before window.close(); – opewix Commented Sep 12, 2012 at 6:38
4 Answers
Reset to default 1Try
window.parent.location.reload();
just try this code in your child window
Page.ClientScript.RegisterStartUpScript(this.GetType(),
"close",
"<script language=javascript>window.opener.location.reload(true);
self.close();</script>");
Example with a link:
<script language="Javascript">
<!-- Start
document.write('<a href="javascript:self.close()" onClick="opener.location.reload(true);">Close</a>');
// Stop -->
</script>
You are closing your child window before your parent window gets refreshed. Try it this way
<string script = @"<script>
function RefreshParent()
{
window.opener.location.reload();
window.close();
}RefreshParent();
</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "ssr", script);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745126601a4612727.html
评论列表(0条)