...

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



coacl
03-01-2004, 04:30 AM
How do sites like these work-

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

Thanks. *A code would help.

glenngv
03-01-2004, 04:42 AM
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 (http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=javascript+random+quotes).

coacl
03-01-2004, 04:50 AM
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.

glenngv
03-01-2004, 05:10 AM
Because the random selection is done on the server-side. The server-side language only outputs the selected quote.

coacl
03-01-2004, 06:10 AM
Glenn: thanks for all the help I finally got what I wanted.

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

Thanks again.

glenngv
03-01-2004, 06:55 AM
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>

coacl
03-02-2004, 02:37 AM
I love it, now I just got to setup a form for guest to add quotes... hmm... http://www.codingforums.com/showthread.php?s=&threadid=34378 -I'm a noob at life.

Thanks again.

glenngv
03-02-2004, 06:57 AM
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.


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.

pozz
03-13-2004, 08:29 AM
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

glenngv
03-15-2004, 01:14 AM
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.

shlagish
03-15-2004, 01:22 AM
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?

pozz
03-15-2004, 11:22 PM
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

whammy
03-16-2004, 02:34 AM
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.

glenngv
03-16-2004, 02:47 AM
Thanks whammy! :thumbsup: :cool:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum