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

匿名 (未验证) 提交于 2019-12-03 02:50:02

问题:

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

回答1:

<body onload="setInterval('window.location.reload()', 120000);">


回答2:

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" />



回答3:

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.



回答4:

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

http://jquery.com/



回答5:

      <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.



回答6:

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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!