user1534353
user1534353

Reputation: 1

how to load this Javascript to my blogspot page?

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

Answers (1)

David
David

Reputation: 4047

It's easy. I've tried it in blogger and working correctly.

  1. Open your blog
  2. Create new post
  3. Use HTML mode and paste the above code
  4. Save your post and check that your HTML code still the same (I tried blogger changed some lines in the end).
  5. Preview your post, you will see text such as Allergic reactions
  6. Close the preview and preview your post again, the text shall be different now, such as Diabetes

You can add any text before and after the javascript (using HTML format of course)

Upvotes: 4

Related Questions