Is there script that shows a random html document, not image

Discussion in 'HTML & Website Design' started by newbiesiteguy, Feb 10, 2006.

  1. #1
    a few days ago, I posted a question asking how to display random images. But actually, I need somthing that displays a random html document, not a random image. I have taken images, inserted them into an html doc and added hotspots to turn them into ads.html
     
    newbiesiteguy, Feb 10, 2006 IP
  2. RectangleMan

    RectangleMan Notable Member

    Messages:
    2,825
    Likes Received:
    132
    Best Answers:
    0
    Trophy Points:
    210
    #2
    That should be the same code as the random image.

    Post the code that creates your random image.
     
    RectangleMan, Feb 10, 2006 IP
  3. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Place the following code precisely where you want your included document to be rotated:
    <? 
    $files = glob($_SERVER['DOCUMENT_ROOT'].'/html_inc/*'); 
    include $files[array_rand($files)]; 
    ?>
    Code (markup):
    Change html_inc to the name of the folder into which your random documents will be stored. Make sure the page is named .php, or that .html is set to be parsed as php by the server.

    And that's it. Just put your documents into that folder, and the server will serve up a random one every time!

    (Credit goes to Sea Otter for this gem).
     
    the_pm, Feb 11, 2006 IP
  4. newbiesiteguy

    newbiesiteguy Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    function randInt(min,max)
    {
    var div = (max - min) + 1
    var randNum = Math.random()
    for (var i = 0; i <= div - 1; i++)
    {
    if (randNum >= i / div && randNum < (i+1) / div)
    {return i + min}
    }
    }


    var abc = randInt(1,5);

    if (abc == 1) {

    document.write("<\"Your 1. HTML-Banner-Code\">");

    }

    if (abc == 2) {

    document.write("<\"Your 2. HTML-Banner-Code\">");

    }

    if (abc == 3) {

    document.write("<\"Your 3. HTML-Banner-Code\">");

    }

    if (abc == 4) {

    document.write("<\"Your 4. HTML-Banner-Code\">");

    }

    if (abc == 5) {

    document.write("<\"Your 5. HTML-Banner-Code\">");

    }



    Activating code:

    <script language="JavaScript" type="text/javascript" src="rotation-script.js">
     
    newbiesiteguy, Feb 11, 2006 IP
  5. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Why do it with JavaScript when you can do it much more cleanly with PHP, plus you don't lose search engines and people browsing without JS enabled?
     
    the_pm, Feb 11, 2006 IP