【发布时间】:2012-01-08 22:27:53
【问题描述】:
这段简单的代码(进度条)在任何地方都可以正常工作,除了 IE(尝试过 9 和 8):
<!-- Progress bar holder -->
<div id="progress" style="width:500px;border:1px solid #eee;"></div>
<!-- Progress information -->
<div id="information" style="width"></div>
<?php
// Total processes
$total = 10;
// Loop through process
for($i=1; $i<=$total; $i++){
// Calculate the percentation
$percent = intval($i/$total * 100)."%";
// Javascript for updating the progress bar and information
echo '<script language="javascript">
document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.'; background-color:#ddd;\"> </div>";
document.getElementById("information").innerHTML="'.$i.' row(s) processed.";
</script>';
// This is for the buffer achieve the minimum size in order to flush data
echo str_repeat(' ',1024*64);
// Send output to browser immediately
flush();
// Sleep one second so we can see the delay
sleep(1);
}
// Tell user that the process is completed
echo '<script language="javascript">document.getElementById("information").innerHTML="Process completed"</script>';
?>
IE 显示错误“无法设置属性‘innerHTML’的值:对象为空或未定义”。 问题似乎在这里:
document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.';background-color:#ddd;\"> </div>";
在这种情况下,div 在 IE 中无法正常工作(至少据我所知)
试图自己修复它,但它对我来说太复杂了。任何帮助都感激不尽。 谢谢)
【问题讨论】:
-
它在 IE 8 上对我来说很好用...您是否尝试过禁用任何插件、加速器等?以及您的安全设置是什么?
-
嗯...尝试了三种完全不同的组合(IE 9,8,6)...没有运气。你看到进度条还是只是容器??
-
看到了酒吧和容器。您是否尝试过禁用插件、加速器等并降低安全设置?
-
我不经常使用 IE,只是为了测试。没有插件或任何东西,基本版本。试图将安全性降至最低水平,但仍然没有。奇怪...
-
嗯...对不起;帮不了你:(
标签: internet-explorer innerhtml