[转]window.showModalDialog 缓存和返回值的问题

这次在开发过程中用到了模态弹出对话框,但这个函数会有缓存,很是烦恼,在网上查了查相关的资料,发现了一种解决的方法,在这里记录下,主要是在给弹出的窗口的页面加上个时间参数,这样就不会有缓存了,如下:

一、缓存

1、

<meta http-equiv="pragma"   content="no-cache" />  
<meta http-equiv="Cache-Control" content="no-cache,must-revalidate" />  
<meta http-equiv="expires" content="Wed,26 Feb 1997 08:21:57 GMT" />

2、

<script language='javascript'>

var time = new Date();

window.showModalDialog("newWin.html?time="+time,"","");

</script>

二、返回值

1、被调用的fish.html

<html>

<title>html</title>

<head>

<script>  
  function   sendTo()  {  
      window.returnValue   =   “deepfish”;
     window.close()  ;
  }  
</script>

</head>  
<body>  
<form>  
    <input   value="返回"   type=button   onclick="sendTo()">  
</form>

</body>

</html>

2、调用者html

<html>

<body>

<script>

  var   tmp   =   window.showModalDialog("fish.htm")  
  alert(tmp);  

</script>

<body>

</html>

来源:http://www.cnblogs.com/xmphoenix/archive/2012/02/11/2347037.html

原文地址:https://www.cnblogs.com/seasons1987/p/2872961.html