1。開啟視窗:
var handle = window.showModalDialog(url, objects, feathers);
其中:objects可以為參數(包括數組),也可以是對象。
通常的用法 objects = {window} ,把父表單的對象共用給子表單。
2。關閉子視窗:
window.close();
3。從子表單傳參數給父表單:
window.returnVal = string;
4。清除緩衝,防止強制回應視窗頁面不更新的情況:
HTML
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Mon, 23 Jan 1978 20:52:30 GMT">
ASP
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
%>
PHP
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
JSP
response.setHeader("Pragma","No-Cache");
response.setHeader("Cache-Control","No-Cache");
response.setDateHeader("Expires", 0);
5。防止開啟新視窗(如提交表單):
<base target="_self">
6。在強制回應視窗使用F5重新整理頁面:
<base target="_self">
<body onkeydown="if (event.keyCode==116){reload.click()}">
<a id="reload" href="filename.htm" style="display:none">reload...</a>
其中:filename為視窗頁面。
7。防止強制回應視窗開啟的頁面出現cookie丟失的情況:
強制回應視窗開啟新視窗時,僅可以使用 showModalDialog(url,window,feathers); 方法,且 objects 為 window 。
8。在快顯視窗中獲得或設定主視窗的任何值:
開啟快顯視窗時用:showModalDialog(url, window, feathers)
在快顯視窗中使用 window.dialogArguments 對象(即主視窗傳遞過來的 window 對象集),即可以獲得或者設定主視窗的值。
9 子頁面關閉同時重新整理父頁面
調用方法
父頁面:openModelWin('ChooseStyle.aspx');
子頁面:closeWin()
指令碼:
function openModelWin(url)
{
var obj = showModalDialog(url,'title',"dialogWidth:600px;");
if(obj =='reload')
{
window.location.reload();
}
}
function closeWin()
{
window.opener = null;
window.close();
window.returnValue='reload';
}