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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript timed redirecting url inside iframe.

    I have oDroid with android operation system and it is connected to TV via HDMI. At the moment it's able to show HTML website with advertisements in an iframe, set to full screen. It boots up, script opens browser, website including iframe with advertisements is there.

    My problem is that i want to show videos and advertisements alternately without any need to click anywhere or something.

    For example: It should open browser, showing 5 minutes of site with advertisements, then redirects to youtube video or playlist, shows 5 minutes of videos and then redirects back to site with advertisements and so on. (should be like loop)

    Is this possible and if it is, how?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,437
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Of course it's possible. And not really hard.

    *ROUGH* idea:
    Code:
    <!DOCTYPE html>
    <html>
    <body>
    ...
    <iframe id="myIframe"></iframe>
    ...
    <script type="text/javascript">
    var showing = [
        "http://www.myads.com/ad17.php",
        "http://www.youtube.com/xxxxxx",
        "http://www.mysite.com/photoalbum.php?album=32",
        ... any number of other urls ...
    ];
    
    var nowShowing = 0;
    function updateShow( )
    {
        document.getElementById("myIframe").src = showing[nowShowing];
        nowShowing = ( nowShowing + 1 ) % showing.length; // will loop at end of list
        setTimeout( updateShow, 5*60*1000 ); // change in 5 minutes
    }
    updateShow( );  // start it up
    </script>
    </body>
    </html>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you.
    I also did some research and mixing your idea with mine took me closer to win.


  •  

    Posting Permissions

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