用frameset做了一个简单的导航页面main.jsp。左边的导航页是link.jsp,右边的目标页(显示内容)是content.jsp。
我点击左边导航页的每一个超级链接,都可以在右侧的content.jsp中显示内容。
但是,如果我想有个退出的链接,退出当前frameset并跳转到index.jsp。
应该怎么操作?
我点击左边导航页的每一个超级链接,都可以在右侧的content.jsp中显示内容。
但是,如果我想有个退出的链接,退出当前frameset并跳转到index.jsp。
应该怎么操作?
我是链接到servlet然后重定向的。
但是跳转后的页面还是显示在右边。
function quitit()
if (top.location == self.location && opener) {
opener.location.replace("<%=path%>/index.jsp");
self.close();
}
else {
top.location.replace("<%=path%>/index.jsp");
}
</script>
<input type ="button" name="qiutit" value="quitit" onclick="quitit()"/>
opener.location.replace(" <%=path%>/index.jsp"); self.close();
}
else {
top.location.replace(" <%=path%>/index.jsp");
} //能具体说一下什么意思吗?
1)先清理session使当前会话无效(否则用户按浏览器的回退按钮一样回到这里,很不安全)
session.removeAttribute("你的保存会话的对象");
session.invalidate();
2)紧接着写一段js
<script type="text/javascript">
self.parent.location.href="退出后你要去的界面的相对路径";
</script>
if (! confirm('您确定要注销系统吗?')) {
return;
}
top.location.href = '<c:url value = '/logoff' />';//logoff你的severlet
}
调用此方法应该就可以了吧
全部是target="_top"。
上层是target="_parent"。
不要只记得怎么改指定id的frame,反倒把html默认的几个target给忘了。
另外,也可以将IFrame中的按钮点击响应指向(或讲调用)Servlet或Action(如果是Struts,总之是调用服务器上的)中的退出方法。如:页面IFrame中:
<a href="***.do?command=logout" target="_top">登出</a><!-- 注意此处的target="_top",说明其打开的窗口在该Frame的父Frame -->Action中对应的logout方法:
public ActionForward logout(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
request.getSession().setAttribute("currentUser", null); //清除该用户信息
return mapping.findForward("指向登录或其它页面");
}
另外,也可以将IFrame中的按钮点击响应指向(或讲调用)Servlet或Action(如果是Struts,总之是调用服务器上的)中的退出方法。如:页面IFrame中:
<a href="***.do?command=logout" target="_top">登出</a><!-- 注意此处的target="_top",说明其打开的窗口在该Frame的父Frame -->Action中对应的logout方法:
public ActionForward logout(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
request.getSession().setAttribute("currentUser", null); //清除该用户信息
return mapping.findForward("指向登录或其它页面");
}