Re: random quote using javascript

by Michael Jon Muehlendorf <haoka(at)wi.tds.net>

 Date:  Fri, 17 May 2002 10:41:26 -0500
 To:  thewolves(at)bigfoot.com
 Cc:  hwg-techniques(at)mail.hwg.org
 References:  nrc
  todo: View Thread, Original
At 07:43 AM 5/17/02 -0700, Larry Coats wrote:
>Martin Clifford wrote:
>
>> You'd have to use DHTML to dynamically change the text in the random fact.
>> 
>> /*Use your random quote script here, but when the user calls the
writeQuote() function that reloads the page on link click, use this instead*/
>> 
>> document.all['quote'].innerHTML = "<b>Thomas Jefferson once said...</b>";
>
>
>
>Of course, document.all and innerHTML are IE-specific (IE versions 4 and 
>up). You'd want to at least do something like:
>
>if (document.all) {
>   document.all['quote'].innerHTML = ...
>}
>
>so that you don't throw alerts at people using other browsers. And you 
>might want to generate your "another random fact?" link with javascript 
>so that you can only have that link appear for browsers that support it.
>
>With some more robust code, you could probably also support Netscape 6 
>and even Netscape 4.
>
>I'd suggest using GetElementById() instead of document.all. You lose IE 
>4, but you gain by having the same code for IE 5+ and Netscape 6, and by 
>using W3C-approved methods. Of course, you could code both ways if you 
>want to keep IE 4.
>
>Larry Coats

Dear Larry and List,

I wish I had a nickel for every time that I have thanked my lucky stars for
joining this list. I hope I'm not embarrassing Larry by complimenting him
publicly, but I just couldn't contain it.

Though I am not presently involved with any projects using these
techniques, like any good "lurker" I typically read all the posts. And I
must say, the wording, style, and ultra-clear content made me so grateful
that we have Mr. Coates and people like him among us.

Kudos to all you webcrafters!

Mike

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA