Jump to content
MakeWebGames

Random Text Display


Klikoka

Recommended Posts

I have only just learnt this and i would like too share it on here.

 

First...

 

Find where you want to add the script.

 

Second...

 

Add this in to the space

 

<script language="JavaScript">
var r_text = new Array ();
r_text[0] = "All the leaves are brown";
r_text[1] = "And the sky is grey";
r_text[2] = "I've been for a walk";
r_text[3] = "On a winter's day";
r_text[4] = "I'd be safe and warm";
r_text[5] = "If I was in L.A.";
r_text[6] = "California dreaming, On such a winter's day";
var i = Math.round(6*Math.random());
document.write(r_text[i]);
</script>

 

Last...

 

Check that the text is displaying on your webpage then add in your own text to it.

 

Resource:Web Developers Notes

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...