在IE上使用jquery访问Iframe内容 [英] Accessing Iframe content using jquery on IE

查看:133
本文介绍了在IE上使用jquery访问Iframe内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用隐藏的iframe上传文件,并得到回应。下面的代码在Firefox上工作正常,但在IE浏览器上打破。它没有得到回应。

I am trying to upload a file using an hidden Iframe and get the response back. The following code works fine on Firefox but breaks on IE. It fails on getting the response back.

Line....
var content = $j(this).contents().find("body:last").text();

任何帮助/建议深表谢意。
Thanks。

Any help/suggestion is deeply appreciated. Thanks.

$j('#uploadForm').submit(function(e) {

        var jThis = $j('#uploadForm');
        var strName = ("uploader" + (new Date()).getTime());
        var jFrame = $j("<iframe id=\"" + strName + "\" name=\"" + strName + "\" src=\"about:blank\" />");
        jFrame.css("display", "none");

        jThis
                .attr("method", "post")
                .attr("enctype", "multipart/form-data")
                .attr("encoding", "multipart/form-data")
                .attr("target", strName)
                ;

        $j("body:first").append(jFrame);

        jFrame.load(function(objEvent) {
            var content = $j(this).contents().find("body:last").text();
            alert(content);

    });
});


推荐答案

试试这个:

Try this:

jFrame.load(function(objEvent) {
    var content = $(this.contentWindow.document.body).html();
    alert(content);
});

这篇关于在IE上使用jquery访问Iframe内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆