【发布时间】:2010-01-29 19:01:44
【问题描述】:
我有一个简单的网站来播放一些 Flash 视频。我将视频及其相关 cmets 的信息存储在 xml 文件中。我使用 SimpleXML 来遍历所有这些内容并按时间倒序显示这些内容。一切都在 IE8、Safari 和 Chrome 中完美运行,但在 Firefox 中,屏幕上的所有视频都显示相同的视频(simpleXML 数组中 [0] 处的那个)。所有相关信息(标题、cmets 等)都是正确的,查看 html 输出显示 FLV 播放器正在调用正确的文件……但 Firefox 不会显示它!
那么:我可以在 php 脚本中解释 Firefox DOM 中的一些怪癖吗?我能做些什么? 页面在这里:http://omega.uta.edu/~ktb7964/
还有一些源代码: PHP 循环:
<?php
//this script uses a few for loops to first count the number of video/comment entries in the related xml file,
//and then count backwards through them so they are all displayed in reverse chronological order.
//$v is the array position for a video element and $c is the array position for a comment element.
for($v=0; $xml->video[$v];$v++) {}
$v--;
for($v; $v >= 0;$v--) {
//the code that declares the FLV player needs to be split into pieces so we can concatenate them with $v.
$script1 = file_get_contents('script1.htm');
$script2 = file_get_contents('script2.htm');
$script3 = file_get_contents('script3.htm');
$script4 = file_get_contents('script4.htm');
echo("<h2>" . $xml->video[$v]->title . "</h2>");
echo($script1 . $v . $script2 . $xml->video[$v]->file . $script3 . $xml->video[$v]->url . $script4);
echo("<h3>Comments:</h3>");
echo("<form action=\"post".$v.".php\" method=\"post\" name=\"postcomment".$v."\">");
echo("<input name=\"position\" type=\"hidden\" value=\"".$v."\" />");
echo("<input name=\"username\" type=\"text\" size=\"30\" maxlength=\"20\" value =\"Username:\" onblur=\"if(this.value=='') this.value='Username:';\" onfocus= \"this.value='';\" /></p>");
echo("<p><textarea name=\"text\" cols=\"50\" rows=\"5\"></textarea></p>");
echo("<input name=\"submit\" type=\"submit\" value=\"Post a Comment\" />");
echo("</form>");
for($c=0; $xml->video[$v]->comments->comment[$c];$c++) {}
$c--;
if($c < 0){
echo("<p><i>No comments yet.</i></p>");}
else {
for($c; $c >= 0; $c--) {
echo("<h4>" . $xml->video[$v]->comments->comment[$c]->poster . " said: </h4>");
echo("<p>" . $xml->video[$v]->comments->comment[$c]->post . "</p>");
echo("<hr />"); }
}
}
?>
还有一段xml文件:
<videos>
<video>
<uid>0</uid>
<title>The Real World: UTA</title>
<file>draft</file>
<comments>
<comment>
<poster>Fooman</poster>
<email>fooman@domain.com</email>
<post>"This video is so exciting!</post>
</comment>
<comment>
<poster>Foogirl</poster>
<email>foogirl@domain.com</email>
<post>"Ha! That was hilarious!"</post>
</comment>
</comments>
</video>
</videos>
谢谢!
【问题讨论】: