我有一个JSP文件,我在其中启动2个应用程序。第一个应用程序从<iframe>
开始,它是不可见的,第二个应用程序只有在第一个应用程序完全加载到<iframe>
之后才需要启动。如何检查第一个应用程序是否已在<iframe>
完全加载?
这是HTML / JS代码(由JSP生成):
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta http-equiv="refresh" content="2">
<script type="text/javascript">
var info = '<%="https://"+request.getServerName()+":"+request.getServerPort()%>';
var username = '<%=request.getParameter("j_username")%>';
var password = '<%=request.getParameter("j_password")%>';
</script>
</head>
<body>
<form method="POST" name="avx" target="_self" style="display:none; visibility:hidden;">
<table width="500" border="0" bordercolor="#999999" align="center">
<tr><td bgcolor="#FFFFFF" class="formtitle01" align="center"><img src="assets/lock.jpg"></td></tr>
<tr><td bgcolor="#FFFFFF" class="formtitle01" align="center">Authentication In Progress</td></tr>
<tr><td align="center"><input type='text' name='j_username' style="display:none; visibility:hidden;"></td></tr>
<tr><td align="center"><input type='password' name='j_password' style="display:none; visibility:hidden;"></td></tr>
</table>
</form>
<iframe id="myFrame" style="display:none; visibility:hidden;">Hidden Text</iframe>
<script type="text/javascript">
document.avx.j_username.value = username;
document.avx.j_password.value = password;
document.avx.action = info+'/avex/j_security_check';
openInfoFrame();
function openInfoFrame() {
var MyIFrame = document.getElementById("myFrame");
MyIFrame.src = info+'/info/j_security_check?j_username='+username+'&j_password='+password+'&submit=login';
}
//window.open(info,'_self');
document.avx.submit();
</script>
</body>
</html>
答案 0 :(得分:3)
<iframe onload="onIframeLoaded();">
应该可以正常工作。
或者在脚本中连接它:
document.getElementById("myFrame").onload = function() { ... };