简体   繁体   English

获取jquery中iframe的内容,替换为父html

[英]Get contents of iframe in jquery and replace it to the parent html

I am trying to get the entire contents from an iframe and replace it to the parent html.我正在尝试从 iframe 获取全部内容并将其替换为父 html。 The sample code is as follows示例代码如下

 $('#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
    });

How do i access the html tag and write content to it in IE7??我如何访问 html 标签并在 IE7 中写入内容?

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

Not sure why this isn't working in IE 7 but i can give you an alternativ solution.不知道为什么这在 IE 7 中不起作用,但我可以给你一个替代解决方案。 That would be to call the page via its url instead.那就是通过它的 url 来调用页面。 So you replace your所以你更换你的

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

With the jquery for loading URL instead.用 jquery 代替加载 URL。

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

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