javascript - 前端frame重新reload,為什么一直報沒有location這個方法?
問題描述
1,我的頁面結構是這樣的:
<frameset rows='72,*,16' border='1' framespacing='0' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'> <frame name='framHeader' src='http://www.aoyou183.cn/wenda/top.aspx' scrolling='no' border='0' frameborder='no' noresize topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'></frame> <frameset name='framMain' cols='250,*' border='0' frameborder='0' framespacing='1' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'><frame name='framLeft' src='http://www.aoyou183.cn/wenda/Left.html' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' frameborder='0' scrolling='no' noresize></frame><frame name='framRight' src='http://www.aoyou183.cn/wenda/right.html' frameborder='0' bordercolor='#e4e4e4' noresize></frame> </frameset> <frame name='framFooter' src='http://www.aoyou183.cn/wenda/foot.html' marginwidth='0' marginheight='0' frameborder='no' scrolling='no' noresize></frameset> <noframes></noframes>
2,登錄后framRight跳轉到welcome.aspx,現在想在welcome.aspx中刷新top.aspx,以便使得登錄名可以顯示在top.aspx中但是怎么弄都無效,求高手幫助。我的寫法:登錄后在welcome.aspx中:
<p> <script>document.getElementsByName('framHeader').window.location.reload(); </script></p>
樓下各位的方法我都試過了,都不好用啊。。。。。
問題解答
回答1:問題終于解決:
<script>
window.parent.parent.frames['framHeader'].window.location.reload();
</script>樓上各位提供的方法是基于當前頁面和要刷新的頁面同處于一個frameset,而我的這個頁面不在當前frameset所以無法跨域刷新,必須找到目標頁面所在的frameset才可以。
回答2:document.getElementsByName('framHeader')[0].window.location.reload();
回答3:getElementsByName 同學,請仔細讀方法名喲
回答4:document.getElementsByName('framHeader')獲得的是一個數組
回答5:可以嘗試一哈這條語句document.getElementsByTagName(’framHeader’)[0].contentWindow.location.reload();
回答6:叫你用那么多 jquery,getElementsByName 返回是數組
![css3 - [CSS] 動畫效果 3D翻轉bug](http://www.aoyou183.cn/attached/image/news/202304/110831f073.png)