I have a jQuery snippet as below:
$.ajax({
....
success: function(myContent) {
.....
$(\'
I believe some browsers need a short delay for it to recognize the DOM of a new iframe. Using a timeout should work:
$('<iframe id="myFrame" name="myFrame">').appendTo("body").ready(function(){
setTimeout(function(){
$('#myFrame').contents().find('body').append(myContent);
},50);
});
This simple code may be use for you, it works fine for me.
$("#iframe_id").contents().find("body").append("Contents to display in iframe");
I think this is what you are looking for:
$('<iframe id="myFrame" name="myFrame">').appendTo('body');
$('iframe').contents().find('body').html(myContent);
Demo: http://jsfiddle.net/vbNGA/1/