`

窗口刷新问题

阅读更多

1.用window.open()方法打开子窗口

在子窗口刷新父窗口:

      window.opener.location.href = window.opener.location.href; (推荐)

      或者:

      window.opener.location.reload();

刷新本窗口:

      window.location.href=window.location.href ; (推荐)
      window.location.reload; 

 

2.iframe刷新问题

刷新iframe:      <iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe>

方案一:用iframe的name属性定位
     <input type="button" name="Button" value="Button"
onclick="document.frames('ifrmname').location.reload()">


<input type="button" name="Button" value="Button"
onclick="document.all.ifrmname.document.location.reload()">

方案二:用iframe的id属性定位
<input type="button" name="Button" value="Button"
onclick="ifrmid.window.location.reload()">

 

终极方案:当iframe的src为其它网站地址(跨域操作时)
<input type="button" name="Button" value="Button"
onclick="window.open(document.all.ifrmname.src,'ifrmname','')">

  可以用document.getElementById("iframname").src=""来进行iframe得重定向;

  在父页面中获取iframe中得参数可以用<input type=button onclick="alert(frames [iframname].document.forms[0].username.value)" value="display username">

刷新iframe的父窗口:

      parent.location.reload() ; 或者 parent.location.href = parent.location.href;

 

3.用window.showModalDialog()方法打开的子窗口刷新父窗口的方法

 function aa(){
  var obj = [window,"a"];
  var pop=window.showModalDialog("b.html",obj,"dialogHeight:600px;dialogWidth:800px;help:0;status:0;scroll:0;resizable:1");
 }

在子窗口中:

var obj = dialogArguments;

pWin = obj[0];

pWin.location.reload();

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics