A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Refresh Page script

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    28

    Refresh Page script

    plz give me a Refresh Page script .that i set a time on page and page auto refresh on my selected time ...

  2. #2
    Junior Member
    Join Date
    Sep 2008
    Posts
    5
    Code:
    <meta http-equiv="refresh" content="20;url=http://www.ibnlive.com/" />

  3. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    28
    dear its automatic refresh on my selected time...there is no time set .

  4. #4
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    dear, what is it you exactly want? pls make it clear

  5. #5
    Junior Member
    Join Date
    Aug 2008
    Posts
    28
    i want to refresh my page on selected time.automatic

  6. #6
    Junior Member
    Join Date
    Sep 2008
    Posts
    5
    the script i had given is automatic refresh only.instead of 20secs replace it by the time which u want to set.

  7. #7
    Junior Member
    Join Date
    Aug 2008
    Posts
    28
    <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>


    this is script u people don,t know any thing

  8. #8
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Quote Originally Posted by mirk4kir
    this is script u people don,t know any thing
    That's harsh. Maybe you should learn better English so we can assist you better. Your initial question was extremely vague.

  9. #9
    Junior Member
    Join Date
    Aug 2008
    Posts
    28
    now i want 2 time page refresh one 12.30 and 2nd time 12.32 how can i ?

  10. #10
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Code:
    <script type="text/javascript">
    var interval = setInterval(function() {
        var h = new Date().getHours();
        var m = new Date().getMinutes();
        if (h == 12) {
            if (m == 30 && window.location.href.indexOf('?rel') == -1) {
                window.location.href += '?rel';
            } else if (m == 32 && window.location.href.indexOf('?rel') != -1) {
                window.location.href = window.location.href.replace(/\?rel$/, '');
            }
        }
    }, 1000);
    </script>

  11. #11
    Junior Member
    Join Date
    Aug 2008
    Posts
    28
    where i select the time?>

  12. #12
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    It refreshes at 12.30 and 12.32 - adjust the values in the if statements to change this. Note it assumes that both the refresh times are in the same hour - you'd need to modify it slightly if you wanted to use times in different hours. For example if you wanted the refresh at 12.30 and 16.15 you might use logic like this,

    Code:
    if (h == 12 && m == 30 && window.location.href.indexOf('?rel') == -1) {
        window.location.href += '?rel';
    } else if (h == 16 && m == 15 && window.location.href.indexOf('?rel') != -1) {
         window.location.href = window.location.href.replace(/\?rel$/, '');
    }

  13. #13
    Junior Member
    Join Date
    Dec 2008
    Posts
    2

    Redirecting instead of refreshing

    Can you kindly change the following script to redirect to an other page instead of refreshing the same page? Thank you in advance

    Code:
    <script type="text/javascript">
                function Page(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(){
                    Page('12.30'); //SPECIFY THE TIME IN 24HRS FORMAT HERE AT WHICH THE PAGE NEEDS TO BE REFRESHED. 
                }, 1000);
            </script>

  14. #14
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Try changing the line,

    window.location.href = window.location.href + "?rel=1";

    to

    window.location.href = "some other address";

  15. #15
    Junior Member
    Join Date
    Dec 2008
    Posts
    2

    Great, thank you!

    Great, this made it! Thank you.

    I am trying to have this same script run based on the server's time. I have found the following script that uses php to get the server time into the client side but I had not found the way to combine the two scripts. Any help would be appreciated.

    It’s pretty easy to get the server time into the client side JavaScript using PHP. The following code will create a JavaScript Date object that holds the current server date/time:

    <script type="text/javascript">
    var dateServer = new Date('<?= date('F d, Y H:i:s') ?>');
    <script type="text/javascript">

    Once that’s done you can work with the dateServer Date object and it will reflect the server’s local date/time. However, what if I need to calculate the date multiple times on-the-fly (e.g. - from within in a loop)? That might come in handy for things like timer scripts. We’ll first need to know the offset between the server time and local time:

    <script type="text/javascript">
    var dateLocal = new Date();
    var dateServer = new Date('<?= date('F d, Y H:i:s') ?>');
    var dateOffset = dateServer - dateLocal;
    <script type="text/javascript">

    dateOffset now holds the offset in milliseconds. Here’s how to make use of the offset for future JavaScript Date object instances:

    <script type="text/javascript">
    var dateLocal = new Date();
    var dateServer = new Date('<?= date('F d, Y H:i:s') ?>');
    var dateOffset = dateServer - dateLocal;

    var newDate = new Date();
    newDate.setTime(newDate.getTime() + dateOffset);
    <script type="text/javascript">

    That’s it! The newDate variable now holds the server time using the calculated offset from the previous PHP date() call.
    Source:
    http://soulpass.com/2007/08/31/worki...cript-and-php/

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center