我有一个页面,它有 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>
Run Code Online (Sandbox Code Playgroud)
topFrame 包括一个注销按钮。但是当我单击注销按钮时,它只是退出 topFrame 其他人保持不变。我怎样才能退出其他框架?在 topFrame 中编写代码似乎不起作用。谢谢!
您可以添加target="_top"
到您的链接,或者您可以使用 javascript 使用您的顶部框架进行导航:
self.parent.location= "URL TO logout";
Run Code Online (Sandbox Code Playgroud)
例子:
<a href="logout.php" target="_top">Logout</a>
<a href="javascript://" onclick="self.parent.location='logout.php'">Logout</a>
Run Code Online (Sandbox Code Playgroud)
另一种选择是,在您注销的页面中,添加一个 javascript 代码以删除将您的文档重定向到顶部框架的框架:
<script type="text/javascript">
if (self.parent.frames.length != 0){
self.parent.location=document.location.href;
}
</script>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5944 次 |
最近记录: |