www.webdeveloper.com
Results 1 to 4 of 4

Thread: Auto refresh with random page

  1. #1
    Join Date
    Dec 2002
    Posts
    112

    Auto refresh with random page

    Need a script that can auto refresh a page in the same frame say after x seconds with a random page/url from a list of pre defined pages/urls.

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    <script type="text/javascript">
    <!--
    Array.prototype.random = function () {return this[Math.floor(Math.random() * this.length)]}

    Date.ONE_SECOND = 1000;

    url = ['fee.html', 'fie.html', 'foe.html', 'fum.html']

    setTimeout('location = url.random()', 5 * Date.ONE_SECOND)
    // -->
    </script>


    It will not work for those who do not use JavaScript so you'll need to provide links to those pages as well.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Dec 2002
    Posts
    112
    This script works fine and opens a random page.
    How can I auto refresh a page (random) in a page using IFRAME?

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    <script type="text/javascript">
    <!--
    Array.prototype.random = function () {return this[Math.floor(Math.random() * this.length)]}

    Date.ONE_SECOND = 1000;

    url = ['fee.html', 'fie.html', 'foe.html', 'fum.html']

    setTimeout('iframeName.location = url.random()', 5 * Date.ONE_SECOND)
    // -->
    </script>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles