Results 1 to 3 of 3

Thread: format text generated by javascript

  1. #1
    Join Date
    Nov 2013

    format text generated by javascript

    I fount the following code to generate random sentences. It work great and I injected the code into my page. However I would like to be able to format the text generated by the script without affecting the format of the remaining parts of my page. Probably this is very easy to do but I am very new at this and was not able to find the way to format only this specific block.
    Many thanks in advance for any help.

    <title>Random Text</title>
    <script type="text/javascript">
    var textarray = [
    "sentence 1",
    "sentence 2",
    "sentence 3",
    "sentence 4" // No comma after last entry

    function RndText() {
    var rannum= Math.floor(Math.random()*textarray.length);
    onload = function() { RndText(); }

    var inter = setInterval(function() { RndText(); }, 2000);

    <div id="ShowText"></div>


  2. #2
    Join Date
    Mar 2011
    It's not clear to me what you have in mind when you say "format". Why not just use CSS to set the styles for your "ShowText" <div>?
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Nov 2013
    Doing what you suggested worked, many thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center