Reputation: 1
Good Day!
Newbie here i found this Javascript in google i have no idea how to insert the result to my new blog post. i want to display a random text to new blog post
<script type="text/javascript">
<!--
//I. Array of banner that will randomly appear
var randomquote = new Array ( );
randomquote[0] = '<em>Allergic reactions</em>';
randomquote[1] = '<em>Dental hygiene </em>';
randomquote[2] = '<em>Diabetes</em>';
randomquote[3] = '<em>Back pain</em>';
randomquote[4] = '<em>Weight loss </em>';
randomquote[5] = '<em>Heat cramps</em>';
randomquote[6] = '<em>Heat stroke</em>';
randomquote[7] = '<em>Pain Medication </em>';
randomquote[8] = '<em>Diet plan</em>';
randomquote[9] = '<em>Dehydration</em>';
//II. function to generate number from 0 to n
function randomzero (n)
{
return ( Math.floor ( Math.random ( )*0.9999999999999999* (n + 1)) );
}
//III. assign any random number from 0 to 2 to x.
x = randomzero(2);
//IV. display the text
document.write(randomquote[x]);
//-->
</script>
thanks in advance.
Upvotes: 0
Views: 590
Reputation: 4047
It's easy. I've tried it in blogger and working correctly.
You can add any text before and after the javascript (using HTML format of course)
Upvotes: 4