/    Sign up×
Community /Pin to ProfileBookmark

How to refresh a page after random times?

I want to refresh a page after random times. Random times are between 30 and 60 seconds. How can I do? Help me, please!!! ?

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@mlimDec 03.2007 — <script>

var count=0

function RefreshPage() { window.location="refresh page 1.htm" }

function Counter() {

count++

if (count==9) RefreshPage()

}

var srcInterval = setInterval("Counter()",500)

</script>

<body>

<h2>Page 0</h2>

<img src=pix1.jpg>

</body>

Copy these codes for Page 1.htm and Page 2.htm
Copy linkTweet thisAlerts:
@xeranaauthorDec 04.2007 — Thank you so much!!! But when I use your code, my pages auto refresh every 5 seconds. I want it auto refresh after random seconds. How? Help me, please!!
Copy linkTweet thisAlerts:
@yearbassDec 04.2007 — like this:

[CODE]<script>
function reloadMe() {
window.location.reload();
}
function getInterval(){
var lowerBound = 30;
var upperBound = 60;

var randNum = Math.floor((upperBound-lowerBound+1)*Math.random()+lowerBound) * 1000;
return randNum;
}
var interval = getInterval();
var srcInterval = setInterval("reloadMe()",interval);
</script>

<body>

<script type="text/javascript">
document.write ("This page will reload after "+interval/1000+" seconds");
</script>

</body>[/CODE]
Copy linkTweet thisAlerts:
@xeranaauthorDec 06.2007 — thank you!
Copy linkTweet thisAlerts:
@xeranaauthorDec 27.2007 — i works very well!!
Copy linkTweet thisAlerts:
@EndzeiterMay 03.2015 — I need a script, too, but it must redirect in random seconds [COLOR="#000000"][B]to another website ![/B][/COLOR]
Copy linkTweet thisAlerts:
@Kevin2May 03.2015 — I need a script, too, but it must redirect in random seconds [COLOR="#000000"][B]to another website ![/B][/COLOR][/QUOTE]

Using the script in post #4 above, change
window.location.reload();

To
window.location = 'http://google.com';
Copy linkTweet thisAlerts:
@beast20Jan 19.2020 — @mlim#831105 Hello mlim please can you tell me how to add that script to page 1.htm and page 2.htm and I want to refresh a webpage once between 1 to 10 mins randomly in loop
Copy linkTweet thisAlerts:
@NachfolgerJan 20.2020 — @beast20#1613338

Please learn propper forum etiquette. **You just bumped a thread from 2007.**
Copy linkTweet thisAlerts:
@VITSUSAJan 20.2020 — @mlim#831105 Yes, it works :)
Copy linkTweet thisAlerts:
@SwagaaoftJan 20.2020 — ReloadmyPage() {

setInterval(() =>{

window.location.reload()

} , 5000)

}

// cLl the function and it will reload your page every 5 seconds.
Copy linkTweet thisAlerts:
@Steve_R_JonesmoderatorJan 20.2020 — {"locked":true}
×

Success!

Help @xerana spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...