Reputation: 595
I found this javascript random text generator from list
var quotes=new Array();
quotes[0] = "text1";
quotes[1] = "Text2";
quotes[2] = "text3";
quotes[3] = "text4";
var q = quotes.length;
var whichquote=Math.round(Math.random()*(q-1));
function showquote(){document.write(quotes[whichquote]);}
showquote();
And html:
<script language="javascript" type="text/javascript" src="quotes.js"></script>
So, it works perfectly, BUT... I want that every text that is generated have specified url, like <a href="#">
Thanks!
Upvotes: 2
Views: 509
Reputation: 2919
As far as I could get what you need, this might do the job:
function showquote(){document.write('<a href="#">' + quotes[whichquote] + '</a>');}
Upvotes: 1