模式窗口showModalDialog的用法總結

模式窗口showModalDialog的用法總結

1。打開窗口:
Code:
var handle = window.showModalDialog(url, objects, feathers);

其中:objects可以爲參數(包括數組),也可以是對象。
通常的用法 objects = {window} ,把父窗體的對象共享給子窗體。

2。關閉子窗口:
Code:
window.close();


3。從子窗體傳參數給父窗體:
Code:
window.returnVal = string;


3。清除緩存,防止模式窗口頁面不更新的情況:
Code:
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);


4。防止打開新窗口(如提交表單):
Code:
<base target="_self">


5。在模式窗口使用F5刷新頁面:
Code:
<base target="_self">
<body οnkeydοwn="if (event.keyCode==116){reload.click()}">
<a id="reload" href="filename.htm" style="display:none">reload...</a>

其中:filename爲窗口頁面。

6。防止模式窗口打開的頁面出現cookie丟失的情況:
模式窗口打開新窗口時,僅可以使用 showModalDialog(url,window,feathers); 方法,且 objects 爲 window 。

7。在彈出窗口中獲得或設置主窗口的任何值:
打開彈出窗口時用:showModalDialog(url, window, feathers)
在彈出窗口中使用 window.dialogArguments 對象(即主窗口傳遞過來的 window 對象集),即可以獲得或者設置主窗口的值。

發佈了56 篇原創文章 · 獲贊 9 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章