I’m trying to place generated variable strings inside an iframe in design mode (richTextEditor). It works beautifully in all browsers except… you guessed it IE. IE won’t process the string variable inside the iframe at all. Here is what I have…
Html (pretty basic)
<iframe name="richTextField" id="richTextField" class="writer"></iframe>
PHP (again very basic) – Disclaimer… mysql_query is not a good practice, will change to PDO later. This is for testing purposes only!
$sql = mysql_query("SELECT * FROM songs WHERE id=$id LIMIT 1") or die();
while($song=mysql_fetch_array($sql)){
$title = $song['title'];
$base_text = $song['song_chart'];
$base_text = str_replace('<br />', '<br>', $base_text);
}
Here is the problem Javascript…
window.frames['richTextField'].document.body.innerHTML = '<?php echo $base_text; ?>';
//I have also tried...
$('iframe').contents().find('body').html('<?php echo $base_text; ?>');
Any help would be greatly appreciated. If I am doing this completely wrong can someone help me with a new direction. Thank You
EDIT
Tested in IE7, IE8, IE9, non functioning in any of them
Try this javascript code