您的位置:首頁技術文章
文章詳情頁

javascript - 前端frame重新reload,為什么一直報沒有location這個方法?

瀏覽:116日期:2023-02-17 18:44:57

問題描述

1,我的頁面結構是這樣的:

<frameset rows='72,*,16' border='1' framespacing='0' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'> <frame name='framHeader' src='http://www.wxshucaidpc.com/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.wxshucaidpc.com/wenda/Left.html' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' frameborder='0' scrolling='no' noresize></frame><frame name='framRight' src='http://www.wxshucaidpc.com/wenda/right.html' frameborder='0' bordercolor='#e4e4e4' noresize></frame> </frameset> <frame name='framFooter' src='http://www.wxshucaidpc.com/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>javascript - 前端frame重新reload,為什么一直報沒有location這個方法?

樓下各位的方法我都試過了,都不好用啊。。。。。

javascript - 前端frame重新reload,為什么一直報沒有location這個方法?

javascript - 前端frame重新reload,為什么一直報沒有location這個方法?

javascript - 前端frame重新reload,為什么一直報沒有location這個方法?

javascript - 前端frame重新reload,為什么一直報沒有location這個方法?

問題解答

回答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 返回是數組

標簽: JavaScript
国产综合久久一区二区三区