日期:2014-05-16 浏览次数:20805 次
<%
	String contextPath = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ contextPath + "/";
	RedirectBean bean = (RedirectBean) request.getAttribute("redirectBean");
	String method = "POST";
	String requestName = "homePage.action";
	if (bean != null) {
		method = ComUtil.changeNullVal(bean.getRequestWay(),method);
		requestName = ComUtil.changeNullVal(bean.getRequest(),requestName);
	}
%>
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RedirectPage</title>
</head>
<!-- <body onload="document.getElementById('autoform').submit();"> -->
<body>
		<form id="autoform" action="<%=requestName %>" method="<%=method%>" target="_top">
			跳转中....
		<%
			if (bean != null) {
				Iterator<SimpleEntry> it = bean.iterator();
				while (it.hasNext()) {
					SimpleEntry en = it.next();
		%>
		<input type="hidden" name="<%=en.getName()%>" value="<%=en.getValue()%>" />
		<%
			}
			}
		%>
	</form>
	<script type="text/javascript">
		document.getElementById('autoform').submit();
	</script>
	</body><div id="target"></div>写到主框架页面的这个div标签中,这个时候应该是自动提交表单的,但是竟然没有跳转!!!然后我发现这个语句
<body onload="document.getElementById('autoform').submit();"> 是不是和主框架页面的某些东西冲突了,onload事件不起作用。果然如此,神奇的javascript,我突然感觉onload事件没什么用,因为我在页面底部如下方法代替就可以执行脚本了,<script type="text/javascript">
		document.getElementById('autoform').submit();
	</script>效果和onload是一样的,页面也约等于load完成了。target="_top",OK,这样这个跳转页面在iframe里提交,就不会和主框架页面冲突了,而且还能跳出iframe提交,也使整个框架页面都返回登录页面。