如何使用javascript代码刷新PHP文件?



我正在编写一个PHP程序从文件夹中获取图像并显示它。我想刷新一下。我不能把javascript代码放在PHP里吗?

<?php
$action = $_REQUEST['action'];
if ($action == "view"){
 $entry =$_GET['al']; 

refreah

代码
   echo '<script type="text/javascript">';
     function refresh(){
     document.images("img1").src="/latimage.php?device=$al&ref=" +  new    Date().getTime();
     var e = document.getElementById("blinker");
     e.style.visibility = ( e.style.visibility == "visible" )? "hidden" : "visible";
     setTimeout("refresh()", 3500);}
 </script>;

您可以使用echo输出JavaScript代码:

echo '<script type="text/javascript">',
    'function refresh() {',
        "document.images('img1').src='/latimage.php?device=$al&ref=' +  new    Date().getTime();",
        'var e = document.getElementById("blinker");',
        'e.style.visibility = ( e.style.visibility == "visible" )? "hidden" : "visible";',
        'setTimeout(refresh, 3500)',
    '}',
'</script>';

Try Like ?> <script> location.reload(); </script> <?php

尝试点赞

?>
<script>
setTimeout(
    document.images("img1").src="/latimage.php?device=$al&ref=" +  new    Date().getTime();
    var e = document.getElementById("blinker");
    e.style.visibility = ( e.style.visibility == "visible" )? "hidden" : "visible";
, 3500);
</script>
<?php

相关内容

  • 没有找到相关文章

最新更新