2011-07-19 36 views
0

我想从iframe中获取整个内容并将其替换为父级html。示例代码如下获取jQuery中的iframe的内容并将其替换为父级的html

$('#textEditor').load(function(){ 
     var test = $('#textEditor').contents().find('html').html(); 
     alert(test); 
     $('html').html(test); // Does not work in IE7 
     $('body').html(test); // Works in IE7 
    }); 

如何访问html标记并在IE7中向其中写入内容?

$('html').html("asdfasdfsad"); // This doesnt work in IE7 
+0

我现在瘦你的页面中有两个html标签...所以这可能会导致第一种情况下的问题 – Vivek

+0

@Vivek No ..我从获得内容,所以这不是问题,它可以完美地工作IE8和其他浏览器除IE7以外:-( – Sullan

回答

0

不知道为什么这不是在IE 7中工作,但我可以给你一个替代解决方案。那将是通过它的url调用页面。所以你更换你的

var test = $('#textEditor').contents().find('html').html(); 

用jquery加载URL来代替。

+0

这是当然如果问题确实是从iFrame获得正确的HTML?或者是插入问题? – Marthin

相关问题