您的位置:首页技术文章
文章详情页

javascript - 前端frame重新reload,为什么一直报没有location这个方法?

【字号: 日期:2023-02-17 18:44:57浏览:68作者:猪猪

问题描述

1,我的页面结构是这样的:

<frameset rows='72,*,16' border='1' framespacing='0' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'> <frame name='framHeader' src='https://www.haobala.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='https://www.haobala.com/wenda/Left.html' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' frameborder='0' scrolling='no' noresize></frame><frame name='framRight' src='https://www.haobala.com/wenda/right.html' frameborder='0' bordercolor='#e4e4e4' noresize></frame> </frameset> <frame name='framFooter' src='https://www.haobala.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