1.怎样防止在showModalDialog和showModelessDialog的弹出窗口里操作,不打开新窗口?
在<head>和</head>之间加<base target="_self">
2.怎样防止模式窗口页面不更新?
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);
以上代码不能解决根本的问题,最好的解决方案是在要打开的文件如filename.htm的后面添加一个无意义的随机数,这样可以根本解决页面缓存的问题。
Example:showModalDialog('filename.htm?rand=随机数','','');
3.怎样在模式窗口使用F5刷新页面?
在<head>和</head>之间加<base target="_self">
<body οnkeydοwn="if (event.keyCode==116){reload.click()}">
<a id="reload" href="file.htm" style="display:none">reload...</a>
其中:file为窗口页面。
4.如何用javascript关掉showModalDialog(或showModelessDialog)打开的窗口?
input type="button" value="关闭" οnclick="window.close()">
也要配合<base target="_self">,不然会打开一个新的IE窗口,然后再关掉的。
5.showModalDialog和showModelessDialog数据传递技巧。
Example:
一般的传递方式:
window.showModalDialog("filename.htm",var_name) //传递var_name变量
在showModalDialog(或showModelessDialog)读取和设置时:
alert(window.dialogArguments)//读取var_name变量
window.dialogArguments="oyiboy"//设置var_name变量
这种方式是可以满足的,但是当你想在操作var_name同时再操作第二个变理var_id时,就无法再进行操作了。这就是这种传递方式的局限性。
另一种传递方式:
window.showModalDialog("filename.htm",window)//不管要操作什么变量,只直传递主窗口的window对象
在showModalDialog(或showModelessDialog)读取和设置时:
alert(window.dialogArguments.var_name)//读取var_name变量
window.dialogArguments.var_name="oyiboy"//设置var_name变量
同时可以操作var_id变量:
alert(window.dialogArguments.var_id)//读取var_id变量
window.dialogArguments.var_id="001"//设置var_id变量
同样还可以对主窗口的任何对象进行操作,如form对象里的元素。
window.dialogArguments.form1.index1.value="这是在设置index1元素的值"
在<head>和</head>之间加<base target="_self">
2.怎样防止模式窗口页面不更新?
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);
以上代码不能解决根本的问题,最好的解决方案是在要打开的文件如filename.htm的后面添加一个无意义的随机数,这样可以根本解决页面缓存的问题。
Example:showModalDialog('filename.htm?rand=随机数','','');
3.怎样在模式窗口使用F5刷新页面?
在<head>和</head>之间加<base target="_self">
<body οnkeydοwn="if (event.keyCode==116){reload.click()}">
<a id="reload" href="file.htm" style="display:none">reload...</a>
其中:file为窗口页面。
4.如何用javascript关掉showModalDialog(或showModelessDialog)打开的窗口?
input type="button" value="关闭" οnclick="window.close()">
也要配合<base target="_self">,不然会打开一个新的IE窗口,然后再关掉的。
5.showModalDialog和showModelessDialog数据传递技巧。
Example:
一般的传递方式:
window.showModalDialog("filename.htm",var_name) //传递var_name变量
在showModalDialog(或showModelessDialog)读取和设置时:
alert(window.dialogArguments)//读取var_name变量
window.dialogArguments="oyiboy"//设置var_name变量
这种方式是可以满足的,但是当你想在操作var_name同时再操作第二个变理var_id时,就无法再进行操作了。这就是这种传递方式的局限性。
另一种传递方式:
window.showModalDialog("filename.htm",window)//不管要操作什么变量,只直传递主窗口的window对象
在showModalDialog(或showModelessDialog)读取和设置时:
alert(window.dialogArguments.var_name)//读取var_name变量
window.dialogArguments.var_name="oyiboy"//设置var_name变量
同时可以操作var_id变量:
alert(window.dialogArguments.var_id)//读取var_id变量
window.dialogArguments.var_id="001"//设置var_id变量
同样还可以对主窗口的任何对象进行操作,如form对象里的元素。
window.dialogArguments.form1.index1.value="这是在设置index1元素的值"