SEO MegaCorp News Blog

8 Users Responded in " Display Random Quote Using JavaScript "

mygif
Manish Pandey said,  

Very interesting script Costin, thanks for putting it up for everybody. :)

mygif
Costin Trifan said,  

I’m glad you like it. :)

mygif
Prashant Vikram said,  

Nice script Costin.

mygif
Chris Tillam said,  

Hi, great script, but how can it be made to trigger from a link on the same page?

I thought I’ might find out from your link
“here is the link –> Random Quote”
but this launches a new page.

Do I take “Quotes.getRandomQuote()” out of the script and do

onclick=”Quotes.getRandomQuote()” ?

mygif
Costin Trifan said,  

yeap,

display random quote

note that you have to return false to prevent the page from being posted back.

mygif
Costin Trifan said,  

arghhh… it made my example look like a live link…

let’s try again:


display random quote

mygif
bryan.o said,  

Hi. This looks good.
Is there a simple way to select part of the text (or preferably add a source text/author name with its own text style) to be a link, which directs the user to an external URL.

For example: random quote is some words from a speech. The link (author’s name) directs user to a web page with the entire speech.

mygif
Costin Trifan said,  

That should be no problem.
All you have to do is to format how the quote and the link are displayed. This is mostly a matter of css.

Example:
Change this:

quote[0] = “When you have given nothing, ask for nothing.”;

to:

quote[0] = ‘[span class='text']When you have given nothing, ask for nothing.[/span][a href="your-url"]author name[/a]‘;

and that should do it.

Leave A Reply Here

  Username [*]

  Email Address [*]

  Website

Subscribes to this post comments updates

Please Note: All comments maybe under going moderation so there is no need to resubmit the comments. it will appeared when admin approved it, feel free to subscribes to the post comments rss to stay update