跳出子視窗新增 / 刪除資料, 再更新(Refresh)母視窗的畫面
所以這邊記錄一下當中做法
[showModalDialog 參數]
dialogHeight | dialogHeight=150px; |
dialogWidth | dialogWidth=400px; |
dialogLeft | dialogLeft=100px; |
dialogTop | dialogTop=50px; |
center | center=yes; |
help | help=no; |
resizable | resizable=no; |
status | status=no; |
scroll | scroll=yes; |
子頁更新母頁:
[母頁.htm]
<script language="javascript">
function OpenChild()
{
DialogParam = "dialogWidth=100px;dialogHeight=400px;";
DialogParam += "status=no;resizable=no";
window.showModalDialog("子頁.htm",window,DialogParam);
}
function RefreshPage()
{
var RefreshLink = document.getElementById("RefreshLink");
RefreshLink.href = "母頁.htm";
RefreshLink.click();
}
</script>
<body>
<a id="RefreshLink" style="display:none"></a>
function OpenChild()
{
DialogParam = "dialogWidth=100px;dialogHeight=400px;";
DialogParam += "status=no;resizable=no";
window.showModalDialog("子頁.htm",window,DialogParam);
}
function RefreshPage()
{
var RefreshLink = document.getElementById("RefreshLink");
RefreshLink.href = "母頁.htm";
RefreshLink.click();
}
</script>
<body>
<a id="RefreshLink" style="display:none"></a>
[子頁.htm]
<script language="javascript">
function RefreshParent()
{
window.dialogArguments.RefreshPage();
}
</script>
function RefreshParent()
{
window.dialogArguments.RefreshPage();
}
</script>
ps.這種方式也適用於showModalDialog出來的視窗
再使用showModalDialog開新視窗
不過,第一個showModalDialog視窗頁面要加一行
<head>
<base target="_self">
因為showModalDialog視窗預設所有Link都會另開視窗<base target="_self">
加了這行後,點選更新畫面Link就會在自己這頁動作
不會另開視窗
這方法不錯喔!!
回覆刪除用在ie 版本8.0.6001上可以跑,在firfox就不行了。