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

查看:163
本文介绍了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="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="Left.html" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" noresize></frame>
        <frame name="framRight" src="right.html" frameborder="0" bordercolor="#e4e4e4" noresize></frame>
    </frameset>
    <frame name="framFooter" src="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中:

<div>
    <script>
        document.getElementsByName("framHeader").window.location.reload();
    </script>
</div>

楼下各位的方法我都试过了,都不好用啊。。。。。


解决方案

问题终于解决:

<script>

window.parent.parent.frames["framHeader"].window.location.reload();

</script>
楼上各位提供的方法是基于当前页面和要刷新的页面同处于一个frameset,而我的这个页面不在当前frameset所以无法跨域刷新,必须找到目标页面所在的frameset才可以。

这篇关于javascript - 前端frame重新reload,为什么一直报没有location这个方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆