页面会在删除后继续发布到iframe

时间:2009-10-30 09:26:12

标签: jquery iframe

$(document).ready(function(){             $(“#uploadSubmit”)。bind(“click”,function(){                 //编辑以下以适应                 var src =“uploader.php”;                 //结束                 var results ='';                 $( “#上传”)追加(结果);                 $(“#uploadResult”)。html('上传请稍候......');                 $(“#uploaderIframe”)。load(function(){                     var iframeHtml = $('#uploaderIframe')。contents()。find(“body”)。html();                     $( “#uploadResult”)HTML(iframeHtml);                     $( “#uploaderIframe”)删除()。                 });             });         });         

效果很好但是一旦iframe被删除,主页面就会继续加载。知道为什么以及如何终止加载?

1 个答案:

答案 0 :(得分:0)

认为这样可行,但没有

<script type="text/javascript">
$(document).ready(function () {
    window.name = "main";
    $("#uploadSubmit").bind("click", function () {
        //edit below to suit
        var src = "uploader.php";
        //end
        var results = '<iframe src="' + src + '" name="uploader" id="uploaderIframe"></iframe>';
        $("#uploader").append(results);
        $("#uploadResult").html('Uploading please wait... <img src="images/loader.gif" />');
        $("#uploaderIframe").load(function () {
            var iframeHtml = $('#uploaderIframe').contents().find("body").html();
            $("#uploadResult").html(iframeHtml);
            $("#uploaderIframe").remove();
            main.execCommand('Stop');
            main.stop();
        });
    }); 
});
</script>