Is there a way to replace the ENTIRE contents of an iframe using Javascript (or Jquery)?
For example if my iframe had the following content...
blah o
have a similar scenario, where I am generating a new iFrame with content from a different domain each time the row of a table is clicked.
To do this, I use jQuery AJAX and PHP. PHP looks at my MySQL table and gets the URL of the iFrame I want to load; it generates the HTML for an iFrame, and I use jQuery AJAX to replace that content.
My HTML looks something like this:
And my AJAX call looks like this:
function loadPage(record_id) {
$.ajax({
type: "POST",
url: "php/ajax_handler.php",
data: "action=makeIFrame&record_id=" + record_id,
success: function(msg){
$('.xFrame' ).html(msg);
}
});
}
The code replaces the HTML of the div that contains the iFrame with a new iFrame.
Hope this (or something similar) works for you.