Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Rotating iframe Source Page

    Hello,
    I need to change the source page of an iframe every 24 hours exactly. I have code that works for every 15 seconds, but when I enter larger numbers, it doesn't work. How can I rewrite this for 86400 seconds? Here is my code:

    <script type="text/javascript">
    var frames = Array('https://www.webpage1.com', 15,
    'https://www.webpage2.com', 15);
    var i = 0, len = frames.length;
    function ChangeSrc()
    {
    if (i >= len) { i = 0; } // start over
    document.getElementById('iframeHome').src = frames[i++];
    setTimeout('ChangeSrc()', (frames[i++]*1000));
    }
    window.onload = ChangeSrc;
    </script>

    Thank you!

  • #2
    New Coder
    Join Date
    May 2005
    Location
    New Zealand
    Posts
    76
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Can you please give example of code that does not work? What is the largest number that has worked for you?

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Posts
    298
    Thanks
    66
    Thanked 8 Times in 8 Posts
    The code you have posted will refresh the iframe once every 24 hours, provided that the browser stays open and on the page containing your script for the entire 24hr period. Is that what you want?

    If not, (i.e., if you want the contents of the iFrame to change once every 24 hours, in any browser, regardless of when or for how long the page is open) then you would be better off doing it in PHP.
    Last edited by XmisterIS; 10-11-2013 at 03:24 PM.

  • Users who have thanked XmisterIS for this post:

    kcelsi (10-14-2013)

  • #4
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes, I want to do what XmisterIS suggested. I need it to change every 24 hours in any browser anywhere. I know a little php, but I don't know how to do this. It's important that I figure this out so could you direct me to a tutorial or give me some code examples of how this would work. Any help you can give would be much appreciated. Thank you.

  • #5
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I found the answer on a php forum.

    http://forums.phpfreaks.com/topic/28...very-24-hours/

    Thank you


  •  

    Posting Permissions

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