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 14 of 14
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do sites like these work- http://www.aonic.net and http://pull.phuzion.com/ ?

    How do sites like these work-

    [URL removed by mod] and http://pull.phuzion.com/ ?

    Thanks. *A code would help.
    Last edited by brothercake; 03-13-2004 at 03:29 PM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    The page is auto-reloaded using the meta tag:

    <meta http-equiv="refresh" content="2.6">

    Every 2.6 seconds, the page will be refreshed.
    The random display of messages is done in the server-side.

    If you want a javascript random quote script, you can find several scripts here.

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankyou, but how come when you view the source of the page the quotes aren't listed- all of the codes I found via google list the quotes in the source.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Because the random selection is done on the server-side. The server-side language only outputs the selected quote.

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Glenn: thanks for all the help I finally got what I wanted.

    http://www.freewebs.com/pozzuolana/ran.htm

    Thanks again.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Actually, you can make the quote changed at an interval without reloading the page.

    Change this:

    var whichquote=Math.floor(Math.random()*(quotes.length))
    document.write(quotes[whichquote])

    to:

    function displayQuote(){
    var whichquote=Math.floor(Math.random()*(quotes.length))
    document.getElementById("quote").innerHTML = quotes[whichquote];
    setTimeout("displayQuote()", 3000); //3 secs interval
    }

    then in your html:
    <html>
    <head>
    <script type="text/javascript" src="http://www.freewebs.com/pozzuolana/ran.js">
    </script>
    </head>
    <body>
    <div id="quote"></div>
    <script type="text/javascript">
    displayQuote();
    </script>
    </body>
    </html>

  • #7
    New Coder
    Join Date
    Mar 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I love it, now I just got to setup a form for guest to add quotes... hmm... Is there a way to allow guests to add lines to a .txt or .js file on my site? -I'm a noob at life.

    Thanks again.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    I suggest not to use fixed interval of 3 secs per quote.
    What happens when the quote is long? You can't read it in 3 seconds.

    My suggestion is to put dynamic interval based on the number of words.
    Code:
    function displayQuote(){
      var whichquote=Math.floor(Math.random()*(quotes.length));
      var q = quotes[whichquote];
      document.getElementById("quote").innerHTML = q;
      setTimeout("displayQuote()", q.split(' ').length*300); 
    }
    Adjust the 300 as needed. This is just my estimate of how long you pronounce a word.
    Not really accurate but more or less "fits" the duration.

  • #9
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great code but it doesn't seem to work for me even though I have the same code as my friend coacl:

    http://pozz.fragism.com/ran.htm
    http://pozz.fragism.com/ran.txt

    The only difference is my quotes but it won't display. Do you have any idea on what might be wrong?

    Perhaps it is the 3000?

    function displayQuote(){
    var whichquote=Math.floor(Math.random()*(quotes.length))
    document.getElementById("quote").innerHTML = quotes[whichquote];
    setTimeout("displayQuote()", 3000); //3 secs interval
    }

    Thanks,
    pozz

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    You have nested single quotes. You have to escape the quote by putting a slash before it.

    quotes[15]='Humans are the only animals that have children on purpose with the exception of guppies, who like to eat theirs. <i>-P. J. O\'Rourke</i>'

    quotes[16]='It is only by not paying one\'s bills that one can hope to live in the memory of the commercial classes. <i>-Oscar Wilde</i>'

    quotes[17]='Then you\'d probably get more then 80 bucks... like a dick up your *** and a "that was sweet". <i>-Pulp</i>'

    Also check the other lines, I found several other lines with nested single quotes.

  • #11
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    also, if I'm not mistaken, a javascript file should have a .js extension...

    <script type="text/javascript" src="http://pozz.fragism.com/ran.txt">
    </script>

    should be:
    <script type="text/javascript" src="http://pozz.fragism.com/ran.js">
    </script>

    and ran.txt should be ran.js (just open it, save as, and replace txt with js)

    Am I wrong?
    Shawn

  • #12
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot Glenn, I didn't notice that.

    And to answer shlagish, I guess the file extension doesn't matter because .txt is working on my page now.

    pozz

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    From GlennGV
    I suggest not to use fixed interval of 3 secs per quote.
    What happens when the quote is long? You can't read it in 3 seconds.

    My suggestion is to put dynamic interval based on the number of words.
    THAT is the kind of post that sets this forum apart from the majority. Clear thinking.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #14
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Thanks whammy!


  •  

    Posting Permissions

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