模式窗口showModalDialog的用法总结

1、打开窗口:
var handle = window.showModalDialog(url, objects, feathers);其中:objects可以为参数(包括数组),也可以是对象。通常的用法
objects = {window} ,把父窗体的对象共享给子窗体。

2、关闭子窗口:
window.close();

3、从子窗体传参数给父窗体:
window.returnVal = string;

4、清除缓存,防止模式窗口页面不更新的情况:

    HTML:
< equiv="pragma" content="no-cache">
< equiv="Cache-Control" content="no-cache, must-revalidate">
< equiv="expires" content="Mon, 23 Jan 1978 20:52:30 GMT">

    ASP:
Response.Expires = -1Response.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、防止打开新窗口(如提交表单):
< target="_self">要放到中

6、在模式窗口使用F5刷新页面:
< target="_self">
< onkeydown="if (event.keyCode==116){reload.click()}">
< id="reload" href="filename.htm" style="display:none">reload…
其中:filename为窗口页面。

7、防止模式窗口打开的页面出现cookie丢失的情况:
模式窗口打开新窗口时,仅可以使用 showModalDialog(url,window,feathers); 方法,且 objects 为 window 。

8、在弹出窗口中获得或设置主窗口的任何值:
打开弹出窗口时用:
showModalDialog(url, window, feathers)在弹出窗口中使用window.dialogArguments 对象(即主窗口传递过来的 window 对象集),即可以

获得或者设置主窗口的值。 
showModalDialog() (Internet Explorer 4 and above) 
showModelessDialog() (Internet Explorer 5 and above) vReturnValue = window.showModalDialog(sURL[, vArguments][, sFeatures]); 
vReturnValue = window.showModelessDialog(sURL[, vArguments][, sFeatures]); 其中: 
vArguments 是要傳到子窗口的參數; 
sFeatures 指定子窗口顯示的狀太,與 window.open() 的相似; sFeatures 所用的參數: 
dialogHeight: iHeight 
dialogWidth: iWidth 
dialogLeft: iXPos 
dialogTop: iYPos 
center: {yes | no | 1 | 0 } 
help: {yes | no | 1 | 0 } 
resizable: {yes | no | 1 | 0 } (Internet Explorer 5 and above) 
status: {yes | no | 1 | 0 } (Internet Explorer 5 and above) 

评论

此博客中的热门博文

你的妈妈已经等了二十几年

时间管理:每天挤出一小时

教您如何认识植柔皮,头层皮革,修面皮革,油蜡皮、水染皮、摔纹皮、纳帕皮、打蜡皮、压花皮、修面皮、漆光皮、磨砂皮、贴膜皮