how to make my php page reload each 2 minutes using javascript?

后端 未结 6 1938
南旧
南旧 2021-02-06 18:47

Every two minutes i want to check whether i received some message so want to reload my page every 2 minutes how to reload my php page using javascript

相关标签:
6条回答
  • 2021-02-06 19:02
    <body onload="setInterval('window.location.reload()', 120000);">
    
    0 讨论(0)
  • 2021-02-06 19:08

    Quick and dirty:

    setTimeout( function() {
        location.reload()
    }, 120000);
    

    Though I think there could possibly be a fancier way of doing this, this is just what I know though.

    0 讨论(0)
  • 2021-02-06 19:12

    I recommend looking into doing it with ajax. Look at the jQuery library, or any of the JavaScript libraries.

    http://jquery.com/

    0 讨论(0)
  • 2021-02-06 19:12
          <meta http-equiv="refresh" content="n">
    

    What if your client doesn't have javascript e.g feature phone browsers? Put that in the head folder of your HTML header. n is the number of seconds for the refresh intervals.

    0 讨论(0)
  • 2021-02-06 19:24

    The easiest way I found out which is also javascript proof.

    This code goes in between the HEAD tags.

    <META HTTP-EQUIV="refresh" CONTENT="15">
    

    The above code reloads the page every 15 seconds. Change 15 to the desired value as required. For eg; 300 for a page to reload every 5 minutes.

    0 讨论(0)
  • 2021-02-06 19:29

    Why are you sticking on javascript. You can do this without Javascript too. <meta http-equiv="refresh" content="2;url=http://path/to/the/page" />

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