PHP - auto refreshing page

后端 未结 8 1360
無奈伤痛
無奈伤痛 2020-12-07 17:52

I am using following code for a refreshing page, it is not reloading on completion. The following code is not working sometime.

 $page = $_SERVER[\'PHP_SELF         


        
相关标签:
8条回答
  • 2020-12-07 18:15

    Use a <meta> redirect instead of a header redirect, like so:

    <?php
    $page = $_SERVER['PHP_SELF'];
    $sec = "10";
    ?>
    <html>
        <head>
        <meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
        </head>
        <body>
        <?php
            echo "Watch the page reload itself in 10 second!";
        ?>
        </body>
    </html>
    
    0 讨论(0)
  • 2020-12-07 18:17

    Simple step like this,

    <!DOCTYPE html>
    <html>
    <head>
        <title>Autorefresh Browser using jquery</title>
        <script type="text/javascript" src="jquery.min.js"></script>
        <script type="text/javascript">
            $(function() {
                startRefresh();
            });
            function startRefresh() {
                setTimeout(startRefresh,100);
                $.get('text.html', function(data) {
                    $('#viewHere').html(data);
                });
            }
        </script>
    
    </head>
    <body>
        <div id="viewHere"></div>
    </body>
    </html>
    

    This video for complete tutorial https://youtu.be/Q907KyXcFHc

    0 讨论(0)
  • 2020-12-07 18:18

    This works with Firefox Quantum 60+ and Chrome v72 (2019)

    //set a header to instruct the browser to call the page every 30 sec
    header("Refresh: 30;");
    

    It does not seem to be NECESSARY to pass the page url as well as the refresh period in order to (re)call the same page. I haven't tried this with Safari/Opera or IE/Edge.

    0 讨论(0)
  • 2020-12-07 18:20

    Try out this as well. Your page will refresh every 10sec

    <html>
     <head>
    
      <meta http-equiv="refresh" content="10; url="<?php echo $_SERVER['PHP_SELF']; ?>">
     </head>
     <body>
    
     </body>
    </html>
    
    0 讨论(0)
  • 2020-12-07 18:22

    use this code ,it will automatically refresh in 5 seconds, you can change time in refresh

    <?php $url1=$_SERVER['REQUEST_URI']; header("Refresh: 5; URL=$url1"); ?>

    0 讨论(0)
  • 2020-12-07 18:22

    <meta http-equiv="refresh" content="10" >

    This can work. Try it..!! :-)

    0 讨论(0)
提交回复
热议问题