2

我有一个 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>
4

1 回答 1

3

<iframe onload="onIframeLoaded();">应该可以正常工作。

或者在脚本中连接它: document.getElementById("myFrame").onload = function() { ... };

于 2011-09-15T13:43:43.120 回答