简体   繁体   English

在iframe中添加了HTML,导致页面重新加载

[英]Added HTML to iframe causes page to reload

I have got the following HTML code: 我有以下HTML代码:

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

In the javascript method, I have; 在javascript方法中,我有;

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. 它的作用是获取从Servlet返回的所有HTML,并将其设置为iframe的HTML。

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. 返回的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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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