href inside javascript


href inside javascript

我试图在页面的右侧构建一个表,我从服务器中取出所有视频。我希望用户单击表中的一行,它开始在页面左侧的流播放器播放视频。视频url是我从数据库中拉出来的东西。

<?php
    for($i=0;$i<$num_videos;$i++)
    {
?>              
        <tr onclick="DoNav('<?php echo $result_videos[$i]["video_url"]; ?>');">
            <td>
...

javascript:

function DoNav(theUrl)
{
  flowplayer("player", "flowplayer/flowplayer-3.2.7.swf", document.location.href = theUrl);
}

无论什么原因,我似乎不能让flowplayer与这个div:

<div id="player"><img src="recordings/landscape.jpg" width="320" height="240" /></div>

它只会提示你打开或保存视频,而不是在当前窗口播放。如果有人知道这个问题,我将不胜感激。无论如何,我知道我可以得到flowplayer工作与href像这样:

<a 
href="url" 
style="display:block;width:320px;height:240px;" 
id="player"><img src="recordings/landscape.jpg" width="320" height="240" />
</a>

但是我不想把href放在表格中,因为我想要那个splash图像也包含在内。什么好主意吗?

编辑以提高清晰度。

当函数flowplayer("player", "flowplayer/flowplayer-3.2.7.swf", document.location.href = theUrl);被称为document.location.href正在被评估,并导致浏览器转到提示文件下载的url。

此外,我们发现在使用子DOM对象更新a时存在某种问题。这是通过使用内联CSS将图像移动到背景来解决的。

JS代码:

function DoNav(theUrl)
{
  flowplayer("player", "flowplayer/flowplayer-3.2.7.swf",  theUrl);
}

HTML表:

<div id="player" style="display:block;width:320px;height:240px;background-image:url(recordings/landscape.jpg)"></div>

PHP保持不变。