简体   繁体   中英

Added HTML to iframe causes page to reload

I have got the following HTML code:

<iframe id="A1B2C3D4E5" frameborder="no" onload="ajaxStandardCall('/myservlet')" style="height:100%;width:100%;border:solid silver 1px;;"></iframe>

In the javascript method, I have;

function ajaxStandardCall(urlString){
     $.ajax({
            type: "POST",
            dataType:'html',
            url: urlString ,
            success: function(msg){
                $("#A1B2C3D4E5").contents().find('html').html(msg);
            },
            failure:  function(msg) {
                $("#A1B2C3D4E5").contents().find('html').html(msg);
            }
     });
}

What is does is that it get whatever HTML returned from the servlet and set it as the HTML of the iframe.

However, when I run this, it shows corrected result page but immediately goes to blank page. It looks to me that it make some other requests to refresh the page.

There is no reload method etc in the return HTML. Is there any obvious mistake of the above code that causes this?

Many thanks

您的iframe必须带有结束标记:

<iframe id="A1B2C3D4E5" frameborder="no" onload="ajaxStandardCall('/myservlet')" style="height:100%;width:100%;border:solid silver 1px;"></iframe>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM