您的位置:首页 > 其它

window.showModalDialog关闭子页面刷新父页面

2010-07-21 09:45 309 查看

这个问题的解决方案有不少,但有些方法总会出问题,下面提一个终极解决办法做参考

思路:在父页面提交一个LinkButton按钮,让其隐藏,关闭子页面的时候让LinkButton onclick事件重新刷新页面。

首先在父页面添加一个LinkButton让其text为空,那么就可以隐藏LinkButton,然后注册这个按钮的js,LinkButton.Attributes.Add("onfocus", "javascript:__doPostBack('btnFresh','');");

添加一段JS代码

var sReturn=window.showModalDialog("" + id,'','dialogWidth:420px;dialogHeight:570px,center=yes,status=no,resizable=no,scroll=no,dialogHide=on');;
if (typeof(sReturn) != "undefined")
{
if (sReturn=="1")
{

document.all["btnFresh"].focus();

}
}

然后在子页面提价一下JS代码

function reload()
{
window.parent.returnValue='1';window.close();
}

因为是showModalDialog 所以记住加入 <base target="_self"/>

00(请您对文章做出评价) //打开模式窗口var id= $("cbH").value;
var num=$("numH").value;
htmUrl=htmUrl+"?id="+id+"&num="+num;

var Width="450";
var Height="200";
var arguemnts = new Object();
arguemnts.window = window;
if (document.all&&window.print)
{
window.showModalDialog(htmUrl,arguemnts,"dialogWidth:" + Width + "px;dialogHeight:" + Height + "px;center:yes;status:no;scroll:yes;help:no;");
window.location.reload();
}
else
{
window.open(htmUrl,"","width=" + Width + "px,height=" + Height + "px,resizable=1,scrollbars=1");
} //关闭模式窗口 function closedialogwindow()
{
window.dialogArguments.window.location = window.dialogArguments.window.location;
self.close(); }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: