PDA

View Full Version : Refresh Page script



mir4kir
09-23-2008, 09:03 AM
help me about this script .i want refresh page on 12.30 at local time its. auto refresh the page on 12.30, and local set time,. can any one help me

codeexploiter
09-23-2008, 09:51 AM
Here is an example which will refresh the page at a give time.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
</style>
<script type="text/javascript">
function refreshPage(tme){
if(new Date().getMinutes() < 10)
var time = new Date().getHours() + ":0" + new Date().getMinutes();
else
var time = new Date().getHours() + ":" + new Date().getMinutes();

if (time === tme) {
clearInterval(glblInterval);
if(window.location.href.indexOf('?rel=1') == -1){
window.location.href = window.location.href + "?rel=1";
}
}else {
if(window.location.href.indexOf('?rel=1') != -1){
clearInterval(glblInterval);
}
return;
}
}

var glblInterval = setInterval(function(){
refreshPage('12:30'); //SPECIFY THE TIME IN 24HRS FORMAT HERE AT WHICH THE PAGE NEEDS TO BE REFRESHED.
}, 1000);
</script>
</head>
<body>
<h1>Test</h1>
<input type="button" value="change" onclick="document.body.getElementsByTagName('h1')[0].innerHTML = 'Changed';"/>
</body>
</html>


1. Save the code.

2. Specify the time at which you want to refresh the page in the following code segment - change the highlighted area (hrs:mins)


var glblInterval = setInterval(function(){
refreshPage('12:30'); //SPECIFY THE TIME IN 24HRS FORMAT HERE AT WHICH THE PAGE NEEDS TO BE REFRESHED.
}, 1000);

3. Now inorder to identify the page refresh, you can click on the 'change' button and wait until the mentioned time. At the correct time the page will be refreshed and the timer will be disabled.

Hope this helps.

mir4kir
09-23-2008, 01:38 PM
sir i want there is no button on page i just upload 2 movies on page and after the selected time which i set like set alarm page can refresh and which 2nd movie i upload play...refresh auto.

mir4kir
09-23-2008, 01:42 PM
its like count down time....means after 30 mint its play and after it will be 12.30 and when 12.30 page can refresh

codeexploiter
09-24-2008, 03:25 AM
The above code is meant for a demo, so when the page loads I just want to give an impression that the page reloads at the mentioned time thats all. You can use the JavaScript code without using the button I've mentioned in my posting. In other words the functionality of the button in my demo page doesn't have anything do with the JavaScript in the page.

You can use only the JavaScript code snippet for your requirement nothing else.

Hope this helps.

mir4kir
09-24-2008, 07:49 AM
i am sorry sir i am new in java i don't understand this script can u clear me..how can i.i am really thanks full to you........u understand na what i want. i just one time set the page refresh option in page and upload to web,and automatic refresh on selected time.

codeexploiter
09-24-2008, 09:00 AM
1. Insert the following code in the page you want to refresh automatically.


<script type="text/javascript">
function refreshPage(tme){
if(new Date().getMinutes() < 10)
var time = new Date().getHours() + ":0" + new Date().getMinutes();
else
var time = new Date().getHours() + ":" + new Date().getMinutes();

if (time === tme) {
clearInterval(glblInterval);
if(window.location.href.indexOf('?rel=1') == -1){
window.location.href = window.location.href + "?rel=1";
}
}else {
if(window.location.href.indexOf('?rel=1') != -1){
clearInterval(glblInterval);
}
return;
}
}

var glblInterval = setInterval(function(){
refreshPage('12:30'); //SPECIFY THE TIME IN 24HRS FORMAT HERE AT WHICH THE PAGE NEEDS TO BE REFRESHED.
}, 1000);
</script>

2. Change the highlighted part in the above code with the time information at which the page needs to be refreshed. Currently I've set it as 12:30. You can change it if you need to specify another time.

Thats all you need to do

mir4kir
09-24-2008, 08:01 PM
thanks you soo much..dear

mir4kir
09-24-2008, 08:35 PM
sir i want to add one thing i want to page refresh 2 time one 12 .30 and one 12.32
how can i?