• 888-750-4777
  • This email address is being protected from spambots. You need JavaScript enabled to view it.
Welcome, Guest
Username: Password: Remember me

TOPIC: How to Add Random Quotes

How to Add Random Quotes 15 years 1 month ago #8473

Joel Smith asked how to add random quotes to his site and I found a script online that will allow you to do this. Create a block, click Source and paste the following. Change the quotes and add additional ones if needed. This will not really help with SEO as search engines don't yet read javascript (but they're trying to learn). But it does look nice if they have a different quote on every page they go to. This would be great for client Testimonials too!

Set up the quotations in the Quotations[] array, then paste in the whole block of code.  To format the text, wrap the usual font tags around the script.

TECH NOTE:

In quotation 8, note the text, \"beauty\" -- if you need
to use double-quote " marks, you *must* precede each
double-quote with a backslash \... otherwise the script
will break.

THE CODE:
<script language="JavaScript">
// ==============================================
// Copyright 2004 by CodeLifter.com
// Free for all; but please leave in this header.
// ==============================================

var Quotation=new Array() // do not change this!

// Set up the quotations to be shown, below.
// To add more quotations, continue with the
// pattern, adding to the array.  Remember
// to increment the Quotation[x] index!

Quotation[0] = "Time is of the essence! Comb your hair.";
Quotation[1] = "Sanity is a golden apple with no shoelaces.";
Quotation[2] = "Repent! The end is coming, $9.95 at Amazon.";
Quotation[3] = "Honesty blurts where deception sneezes.";
Quotation[4] = "Pastry satisfies where art is unavailable.";
Quotation[5] = "Delete not, lest you, too, be deleted.";
Quotation[6] = "O! Youth! What a pain in the backside.";
Quotation[7] = "Wishes are like goldfish with propellors.";
Quotation[8] = "Love the river's \"beauty\", but live on a hill.";
Quotation[9] = "Invention is the mother of too many useless toys.";

// ======================================
// Do not change anything below this line
// ======================================
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>

Please Log in to join the conversation.

Dominic Maricic
Home Inspector Pro Home Inspection Software - CEO

Re: How to Add Random Quotes 15 years 1 month ago #8481

Hey Dom can you show us how this quote will look here in the forum?  That way we can see an example before we try something like that on our sites.

Please Log in to join the conversation.

HLC Home Inspections LLC
www.OklahomaHomeInspector.biz
We are a licensed inspector for the state of Oklahoma.?  Our focus is Oklahoma City, Moore, Mustang, Yukon, Tuttle, and many other areas surrounding OKC.
HLC-Home-Inspections-Oklahoma-City

HLC Home Inspections LLC...

Re: How to Add Random Quotes 15 years 1 month ago #8483

I can't insert javascript into the forum but I'm sure Joel will get it up on his site and we use his site as an example.

Please Log in to join the conversation.

Dominic Maricic
Home Inspector Pro Home Inspection Software - CEO

Re: How to Add Random Quotes 15 years 1 month ago #8499

Okay thanks

Please Log in to join the conversation.

HLC Home Inspections LLC
www.OklahomaHomeInspector.biz
We are a licensed inspector for the state of Oklahoma.?  Our focus is Oklahoma City, Moore, Mustang, Yukon, Tuttle, and many other areas surrounding OKC.
HLC-Home-Inspections-Oklahoma-City

HLC Home Inspections LLC...

Re: How to Add Random Quotes 15 years 1 month ago #8785

Ok, I've succeeded in getting the code inserted with a few sample tip phrases, but am new to website development and html coding, so I have been unable to insert any type of formatting to the quotes, such as centering and font color. Whatever I do - any insertion of formatting code anywhere in the source section - usually just makes all text disappear and then the only way to get it back is to delete the entire block and start over. Sometimes even just deleting the code I inserted will not return the quotes to the web page.

Also, I created the quotes in the format of the script using Notepad, then tried to delete the sample's in Dominic's initial post, and insert mine. But, it did not work, so I had to delete the text from the original code while in the source section and insert the text for each quote there. That works, but is more tedious than creating a list of quotes in Notepad.

Anyway, you can see the results at: marylandenergyauditor.com but if you go there while I happen to still be working on it, you might not see anything!  :(

Dominic, can you provide more details on how to wrap the font attributes around the script?

Thanks

Please Log in to join the conversation.

Joel Smith
Therma-Check
Link URL: www.marylandenergyauditor.com
Body: Home Energy Audits and Thermal Imaging in Maryland, Baltimore Metro Region and Hanover, PA
Key Words: Maryland home energy audit, Baltimore, thermal imaging
Meta Desc: Maryland Energy Audits
URL Path: maryland-energy-auditor
Last Edit: by Joel E. Smith.

Re: How to Add Random Quotes 15 years 1 month ago #8799

To get font attributes the best way is create a test page and insert your quotes then click Source and copy the code for the quote. Note that you need a \ before any " that appear in your code.

For example
<font color=\"red\">This quote will appear in red</font>
<font size=\"3\">This quote will appear in size 3</font>
<font size=\"3\" color=\"red\">This quote will appear in size 3 and be red!</font>

Please Log in to join the conversation.

Dominic Maricic
Home Inspector Pro Home Inspection Software - CEO
Time to create page: 0.186 seconds
© 2004-2024 Home Inspector Pro Inc. All Rights Reserved.