Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:38:50+00:00 2026-06-12T18:38:50+00:00

I am programming a web page, which will a different message every 4 seconds.

  • 0

I am programming a web page, which will a different message every 4 seconds. I have built a custom object which I intend to pull information from to create the strings to be displayed. I’m using a function similar to Math.random called ‘rand’ which will let me access the object randomly. I’ve set the interval for 4 seconds. I can get the string to be displayed, but after that the web page continues to load and load and begins to lag so badly that I have to exit out. The code I’m using is shown below. Please help!

  var name = "Barack Obama";

  var Actions = {

    "ActionList" : [

        { "action" : "watches a 30 minute TV show",
          "time"   : 30,
          "time_measure" : "minute",
          "assuming" : "assuming he sat through the commercials too"
         },

        {
          "action" : "makes some pizza rolls",
          "time" : 9,
          "time_measure" : "minute",
          "assuming" : "he only made one plateful"
         },

        {
          "action" : "takes a 2 hour nap",
          "time" : 2,
          "time_measure" : "hour",
          "assuming" : "assuming he's a heavy sleeper"
         },

        {
          "action" : "1000 jumping jacks",
          "time" : 1,
          "time_measure" : "hour",
          "assuming" : "he doesn't take a break, or slow down"
         }
    ]

  };

  function rand(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }
  function run() {

    /**
     * RANDOMLY SELECT OBJECTS
    ***/
    var r = rand(0, 3);

    var x = Actions.ActionList[r]["action"];

    document.write( x );

  }



  setInterval(run, 4000);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:38:52+00:00Added an answer on June 12, 2026 at 6:38 pm

    http://jsfiddle.net/aHrpC/2/

    This JSFiddle has a working example. It had to do with document.write. Everything else in your code is working correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a html web page which gets a user input in the
Are there any issues with changing elements which will appear on a web page
I am new to web programming and my first draft of a web page
A friend of mine is programming a web page. Instead of writing any HTML
I am new to web programming and Visual Web Developer. I have made a
I am exploring the option of querying a web-page, which has a CGI script
I am relatively new to ASP.NET programming, and web programming in general. We have
I have Web page in share-point 2010 ,its has two web parts one for
I have a web page with links pointing to downloadable files. For example: http://www.mysite.com/download.php?FILE=downloads/programming/various/ebook.pdf
I am new at web programming and learning concepts. I have a question about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.