2

I have a JSP file in which I am starting 2 applications. The first application is starting through an <iframe> which is invisible and second one needs to started only after that the first application is fully loaded in that <iframe>. How can I check if the first application is fully loaded in that <iframe>?

Here's the HTML/JS code (which is generated by a 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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
kc1212
  • 21
  • 1
  • 2

1 Answers1

3

<iframe onload="onIframeLoaded();"> should work just fine.

Or to wire it up in script: document.getElementById("myFrame").onload = function() { ... };

Michael Sandino
  • 1,818
  • 1
  • 13
  • 10