简体   繁体   中英

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. 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').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. That would be to call the page via its url instead. So you replace your

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

With the jquery for loading URL instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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