Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
永久循环php代码中的javascript不起作用_Javascript_Php - Fatal编程技术网

永久循环php代码中的javascript不起作用

永久循环php代码中的javascript不起作用,javascript,php,Javascript,Php,好的,我需要一个程序,在一天内1小时内显示一个1小时长的视频,然后在接下来的23小时内显示一个图像。 视频工作正常,但在视频div处于活动状态时,图像也会显示,而不是隐藏。似乎js根本不起作用,我也不知道为什么。只使用Javascript,我还没有测试它: <html> <head> </head> <body> <div> <object width="100%"

好的,我需要一个程序,在一天内1小时内显示一个1小时长的视频,然后在接下来的23小时内显示一个图像。
视频工作正常,但在视频div处于活动状态时,图像也会显示,而不是隐藏。似乎js根本不起作用,我也不知道为什么。

只使用Javascript,我还没有测试它:

<html>
    <head>
    </head>
    <body>
        <div>
            <object width="100%" 
                    height="100%" 
                    id="liveTV_api" 
                    name="liveTV_api" 
                    data="http://www.extratv.gr/media/imgs/flowplayer-3.2.15.swf"    type="application/x-shockwave-flash">
               <param name="allowfullscreen" 
                      value="true">
               <param name="allowscriptaccess" 
                      value="always">
               <param name="quality" 
                      value="high">
               <param name="bgcolor" 
                      value="#000000">
               <param name="flashvars" 
                      value="config={&quot;clip&quot;:{&quot;url&quot;:&quot;mpegts_256.stream&quot;,&quot;provider&quot;:&quot;rtmp&quot;,&quot;live&quot;:true,&quot;scaling&quot;:&quot;fit&quot;},&quot;plugins&quot;:{&quot;rtmp&quot;:{&quot;url&quot;:&quot;http://www.extratv.gr/media/imgs/flowplayer.rtmp-3.2.11.swf&quot;,&quot;netConnectionUrl&quot;:&quot;rtmp://213.16.167.186:1935/live&quot;,&quot;subscribe&quot;:true}},&quot;playerId&quot;:&quot;liveTV&quot;,&quot;playlist&quot;:[{&quot;url&quot;:&quot;mpegts_256.stream&quot;,&quot;provider&quot;:&quot;rtmp&quot;,&quot;live&quot;:true,&quot;scaling&quot;:&quot;fit&quot;}]}">
            </object>
            <img id="adtv" src="img.png">
      </div>
<?php
set_time_limit(0);
$x=1;
while(x==1) {
   $now = date('G',time());
   $start = 12;
   $end = 13;

  if($now >= $start && $now <= $end):
     echo '<script type="text/javascript">document.getElementById("adtv").style.display="none"; </script>';
     echo '<script type="text/javascript">document.getElementById("liveTV_api").style.display="block"; document.getElementById("adtv").style.display="none";</script>';

   else:
     echo '<script type="text/javascript">document.getElementById("adtv").style.display="block"; document.getElementById("liveTV_api").style.display="none";</script>';
   endif;

   sleep(3600);
}

?>

    </body>
</html>

函数更新(){
var now=(新日期()).getHours(),
开始=12,
结束=13;

如果(现在>=start&&now PHP在服务器上运行。Javascript在客户端上运行。您想要的基本上是不可能的。浏览器正在等待服务器响应…此处的无限循环可能会超时。请删除循环,并在一小时的最晚时间刷新客户端(Javascript)
<html>
<head>
</head>
<body>
<div>
<object width="100%" height="100%" id="liveTV_api" name="liveTV_api" 
data="http://www.extratv.gr/media/imgs/flowplayer-3.2.15.swf" type="application/x-shockwave-flash"><param 
name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="quality" 
value="high"><param name="bgcolor" value="#000000"><param name="flashvars" value="config={&quot;clip&quot;:{&quot;url&quot;:&quot;mpegts_256.stream&quot;,&quot;provider&quot;:&quot;rtmp&quot;,&quot;live&quot;:true,&quot;scaling&quot;:&quot;fit&quot;},&quot;plugins&quot;:{&quot;rtmp&quot;:{&quot;url&quot;:&quot;http://www.extratv.gr/media/imgs/flowplayer.rtmp-3.2.11.swf&quot;,&quot;netConnectionUrl&quot;:&quot;rtmp://213.16.167.186:1935/live&quot;,&quot;subscribe&quot;:true}},&quot;playerId&quot;:&quot;liveTV&quot;,&quot;playlist&quot;:[{&quot;url&quot;:&quot;mpegts_256.stream&quot;,&quot;provider&quot;:&quot;rtmp&quot;,&quot;live&quot;:true,&quot;scaling&quot;:&quot;fit&quot;}]}"></object>
<img id="adtv" src="img.png">
</div>

<script type="text/javascript">

function update() {
    var now = (new Date()).getHours(),
      start = 12,
      end = 13;

    if(now >= start && now <= end) {
        document.getElementById("adtv").style.display="none";
        document.getElementById("liveTV_api").style.display="block";
    }
     else {
        document.getElementById("adtv").style.display="block";
        document.getElementById("liveTV_api").style.display="none";
    }
}

// repeat interval in milliseconds
window.setInterval(update, 3600000);

update();

</script>

</body>
</html>