【发布时间】:2009-06-04 17:25:16
【问题描述】:
部分代码:
下面的代码从我的数据库中提取一个查询,然后使用 inner.HTML = 在 div 中显示数据。它在原始用途中运行良好....
但是,在 iFrame 中调用以下版本,因为它用于更新页面。
页面没有错误,JavaScript 会触发,但最后一行不起作用...
我刚刚意识到,也许因为它是在隐藏的 iFrame 中加载,所以它试图在 iFrame 中设置 div 的 innerHTML,这当然不起作用。
这是怎么回事?这没有任何意义,因为我有另一个脚本以相同的方式在其末尾调用 JavaScript,并且它工作正常。
<?php
while ($row = mysql_fetch_array($result))
{
$p = $p.'<div id="left"><img src="http://www.sharingizcaring.com/bleepV2/images/thumbs/'.$row[image].'" /></div>';
$p = $p.'<div id="right"><h2>'.$row[artist].' - '.$row['title'].'</h2><br>'.$row['message'].'<br>';
$p = $p.'<a href="http://www.sharingizcaring.com/bleepV2/'.$row[username].'">'.$row[username].'</a> '.$row[date].'</div>';
$p = $p.'<div style="clear: both;"></div>';
$p = $p.'<div id="dotted-line"></div>';
}
$p = addslashes($p);
?>
<script>
alert('posts are firing? ');
document.getElementById('posts').innerHTML = 'why doth this faileth?';
</script>
【问题讨论】:
标签: javascript iframe