Populating the contents of 2 iframes with the same HTML preview. Although for one of the iframes I need to modify the data/html by removing the images.
$.ajax({
url: '',
dataType: 'text',
success: function(data) {
if(data){
var iframe = document.getElementById('preview');
iframe.parentNode.style.display = "block";
iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument;
iframe.document.open();
iframe.document.write(data);
iframe.document.close();
var iframe = document.getElementById('preview-noimgs');
iframe.parentNode.style.display = "block";
iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument;
iframe.document.open();
var $data = $(data);
$data.find("img").removeAttr("src");
iframe.document.write($data.html());
iframe.document.close();
}
}
});
This gives me: NULL or [object Object] depending if I add .html()
What is the correct way to modify the source?
Reading through the jquery docs I found parseHTML() but sadly wont be able to use this because we are restricted to version 1.7.1 is there another way to do this?
Preview: http://jsbin.com/cuqarica/2/edit