我试图在设计模式(richTextEditor)下将生成的变量字符串放置在 iframe 中。它在所有浏览器中都能完美运行,除了……你猜对了 IE。 IE 根本不会处理 iframe 内的字符串变量。这是我所拥有的...
Html(非常基本)
<iframe name="richTextField" id="richTextField" class="writer"></iframe>
PHP(同样非常基础)- 免责声明...mysql_query 不是一个好的实践,稍后将更改为 PDO。这仅用于测试目的!
$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);
}
这是 Javascript 的问题...
window.frames['richTextField'].document.body.innerHTML = '<?php echo $base_text; ?>';
//I have also tried...
$('iframe').contents().find('body').html('<?php echo $base_text; ?>');
任何帮助将不胜感激。如果我做的完全错误,有人可以帮助我找到新的方向。谢谢您
编辑
在 IE7、IE8、IE9 中测试,在其中任何一个中都不起作用
最佳答案
试试这个 JavaScript 代码
window.frames['richTextField'].document.write('<?php echo $base_text; ?>');
window.frames['richTextField'].document.designMode="on";
关于php - 将内容放入 iframe 中(在 ie 中中断),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12486072/