我有一个包含4个框架的页面,代码如下
<frameset id = framset_page rows="30,*" cols="*" border="0">
<frame name="topFrame" id="topFrame" noresize scrolling="NO" src="topFrame.jsp">
<frameset cols="200,50,*">
<frame src="FramesetLeftFrame.jsp" />
<frame src="middle.html" />
<frame src="FramesetRightFrame.jsp" />
</frameset>
</frameset>
topFrame包含一个注销按钮。但是当我单击注销按钮时,它只是退出了topFrame,其他保持不变。我怎么也可以退出其他框架?在topFrame中编写代码似乎不起作用。谢谢!
最佳答案
您可以将target="_top"
添加到链接中,也可以使用javascript在顶部框架中进行导航:
self.parent.location= "URL TO logout";
例子:
<a href="logout.php" target="_top">Logout</a>
<a href="javascript://" onclick="self.parent.location='logout.php'">Logout</a>
另一种选择是,在注销页面中,添加javascript代码以删除将文档重定向到顶部框架的框架:
<script type="text/javascript">
if (self.parent.frames.length != 0){
self.parent.location=document.location.href;
}
</script>
关于javascript - 如何从多个框架注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3465208/