Results 1 to 9 of 9

Thread: Refresh Page script

  1. #1
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Refresh Page script

    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

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Here is an example which will refresh the page at a give time.

    Code:
    <!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)

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

  3. #3
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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

  5. #5
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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.

  6. The Following User Says Thank You to codeexploiter For This Useful Post:

    mir4kir (09-28-2008)

  7. #6
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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.

  8. #7
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    1. Insert the following code in the page you want to refresh automatically.
    Code:
    <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

  9. The Following User Says Thank You to codeexploiter For This Useful Post:

    mir4kir (09-28-2008)

  10. #8
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    thanks you soo much..dear

  11. #9
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    sir i want to add one thing i want to page refresh 2 time one 12 .30 and one 12.32
    how can i?
    Last edited by mir4kir; 09-26-2008 at 01:59 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •