Question:
(JS/PHP) Trouble-shooting JS page refresh after 20 sec?
Nicholas J
2011-07-17 11:15:31 UTC
This function im making refreshes the page every 20 seconds, however it doesnt seem to work?

On a side note, the reason im doing it this way is because it a part of a larger function that checks the connection first before refreshing(to avoid ugly "not connected" error pages that come w/ browsers) The function works, dont ask how im checking the connection... be patient, wait for it to be completed before asking for it.

PS
The actual time that it will wait before refreshing when its done is closer to 30 minutes, and when the function is finished you will be able to adjust it on the fly. 20 seconds is just a lot easier to test with.

Better than Pastebin:
http://chopapp.com/#t2mggm8p

Pastebin:
http://pastebin.com/RRPGbVLp
Three answers:
Silent
2011-07-17 11:24:07 UTC
You seem to be making this much more complicated than it needs to be.



Why don't you just use JavaScript's setInterval() to refresh the page every 20 seconds? Why is any PHP code involved here at all?



Edit:

I understand what you're trying to do. I don't understand why you need to check if it's been 20 seconds every 3 seconds. Perhaps if you posted the rest of the code, it would be more clear.
Gitlez
2011-07-19 11:34:49 UTC
Why are you messing around with php's timestamp?!? Simply use Javascript, set a variable for the current time when the page loads, then compare to that. No need to adjust for differing times or timezones.



Try this:



var refreshRate = 20; // Seconds to reload

var t_load = new Date().getTime(); // Time of page Load;

function RefreshThePage() {

if(((new Date().getTime() - t_load)/1000) > refreshRate){

window.location.reload();

}

}

window.onload = function(){setInterval( RefreshThePage,(refreshRate*1000));}





http://pastebin.com/raw.php?i=awr3Jsa2



Most laptops do not do that.



If your goal is custom error pages, then google 'custom error pages .htaccess'. It will be a whole lot easier than your approach.





Cheers,

Gitlez
2016-12-01 02:35:25 UTC
even with what you opt for for to place in writing approximately, verify you think of heavily. like each and every politically charged project it truly is ordinary to from an opinion and write from that perspective truly than to collect info and write from the perspective of an impartial provider of information. P.S. i could desire to be helpful to verify the posts first. i'm able to't enable this one circulate... lack of understanding isn't a distinctive function, and neither is stupidity. pay interest type (particularly you c321Arty) entering into the national shield became no assure of fending off provider in Viet Nam. elementary actuality for the ignorant and stupid available. outline your self, in case you think of that's incorrect you're one or the different. concerning this AWOL bull... It comes from the reality Bush became no longer evaluated for a era jointly as interior the shield, in specific around the time he became in Alabama. back, in case you think of that's precise, you're the two stupid or ignorant. while you're stupid, i'm able to't help you. while you're purely ignorant, i'm going to attempt to enlighten you. Bluntly the argument stems from the reality he became "no longer stated" for a periodic assessment, and likewise that he lost flight status because of fact he did no longer get an annual actual. The "no longer stated" is extremely in specific specified in his checklist and states he became no longer stated because of fact he have been on the command for too short a era. elementary as that, no longer something extra, no longer something much less. He did no longer get a actual because of fact he transferred to a non flight unit which did no longer have a flight healthcare professional. elementary. those ignorant human beings attempt to make a super deal fo the reality he asked a circulate some situations, became denied a minimum of once or twice etc. it truly is ridiculous. As I stated those all of us is the two ignorant or stupid...nicely i did depart out liars. it truly is truly in all probability a three way combination. In any experience the portrayal of Bush as a draft dodger, a deserter etc. is stupid. i'm a vet myself, i'm basically addressing this for the convenience of people who're purely ignorant.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...