Questions tagged [setinterval]

setInterval is a global JavaScript method. It is used to execute a particular function or piece of code at regular intervals.

Tag usage

The tag is appropriate for questions involving the setInterval method.

Implementation

The primary implementation of setInterval receives as arguments a JavaScript function and a number indicating the number of milliseconds in the interval. Ideally, the function would run at the given interval, but this is not always the case if the execution of the function takes longer than the interval. In such a case, MDN recommends using setTimeout instead.

The first parameter to setInterval may also be a code string instead of an actual function, but this usage is generally not recommended for the same reasons that using eval() is frowned upon.

References

4714 questions
1
vote
2 answers

How to initiate a setInterval function with 0 sec but repeat it for a given time?

I'm currently using a setInterval function so that I can repeat text with an extra letter added to it for every 5 secs, hence I've set the time period for the setInterval function as 5000. But I also want this function to be executed as soon as the…
Harish
  • 1,193
  • 6
  • 22
  • 45
1
vote
2 answers

Microsoft Edge: setInterval() callback called concurrently with print()

I found what looks to be a bug in Microsoft Edge. The callback to setInterval() is sometimes called while print() is executing. This results in 2 JavaScript functions running in parallel which shouldn't be allowed, right? The behavior can be…
Mike
  • 11
  • 4
1
vote
2 answers

Loop over a function that uses setInterval (jQuery )

I want show and hide a progress bar 10 times. That's why I use a for loop, in which I call the function oneLoop. oneLoop calls the frame function every 100sec. Frame function is used to change the progress bar. However, the for loop is executed…
themis93
  • 119
  • 1
  • 9
1
vote
2 answers

JavaScript setInterval function only fades in text once

I want my code to fade text in and out using setInterval function in JavaScript. Currently it will only run my first piece of text and then keeps repeating the last bit over and over again. I'm not sure if it's JavaScript or my html.
ncirl.eva
  • 15
  • 5
1
vote
0 answers

How to handle the countdown with setTimeout and Interval in Javascript

I have worked in capturing the user in the application, after login. After login I capture the users session with JavaScript's interval functions The Interval functions trigger every minute. when the users session exceeds 1 minute in the app, it…
Mohamed Sahir
  • 2,482
  • 8
  • 40
  • 71
1
vote
1 answer

Using the setInterval(), how does the age go up at "if"?

this is one of my first questions to ask on this website so please do tell me if I am approaching this the wrong way. Anyways, in my obj i've created (dog), I have a "live" function that counts the age of my dog starting from age (5) by using the…
yunjae123
  • 29
  • 4
1
vote
1 answer

Restarting program when interval time is updated

I have a node js program, which needs to run every 'x' amount of seconds. I have simplified my program, in order to see if there is a solution for my question. This is my program: defaultPoll.find(function (err, interval) { if (err) return…
noDe1
  • 331
  • 1
  • 5
  • 15
1
vote
2 answers

Trying to apply setInterval in my clock unsuccessfully

I teaching myself JavaScript and trying to code something everyday. I'm currently trying to build a simple clock, but I' can't seem to get my setInterval to work. I've tried positioning it in different places, but I think it belongs to the 'time'…
1
vote
3 answers

setInterval at 1ms doesn't seem to actually be 1ms

I'm trying to time how long a file takes to download using an HTTPRequest like so: function getFile() { 'use strict'; var url = "data.bin"; var rawFile = new XMLHttpRequest(); var timer_var = setInterval( theTimer, 1 ); …
Dan
  • 2,304
  • 6
  • 42
  • 69
1
vote
1 answer

How to rotate an array of values within specific tag that contains a unique class by interval in jquery?

In the below piece of code I tried to make the objects with class "rot" to change the inner HTML by using the value attribute that includes an array of chars. I want that this characters will rotate with an interval. I noticed that the problem is in…
benny
  • 11
  • 1
1
vote
2 answers

Function name in setInterval

I have a page in a MVC app that uses setInterval for firing a JavaScript function, calling it by its name. There are several buttons and links that, when the user clicks them, they make ajax calls to the database. Not just that, it also clears the…
1
vote
3 answers

Javascript variable interval

I need to teletype a message but I would like a random interval between letters. This is my code for a constant interval: $( document ).ready(function() { var message = 'Is it possible to create a random interval in javascript?'; var intervalId…
profimedica
  • 2,716
  • 31
  • 41
1
vote
1 answer

publisher subscribber pattern in nodejs sampel code is not woring with out setinterval

I am trying to implement pub/sub as shown below publisher.js var zmq = require('zmq'); var pub = zmq.socket('pub'); pub.bindSync('tcp://127.0.0.1:5555'); pub.send('pub msg'); /* setInterval(function(){ console.log("sending…
dhana lakshmi
  • 847
  • 1
  • 12
  • 29
1
vote
1 answer

How to stop node-server based interval script?

I am creating an application in Nodejs using Expressjs framework. I was try to execute some script after every minute using setInterval() JavaScript method. When I start my server by node app.js the script run successfully. But when I stop the…
Tahir
  • 483
  • 1
  • 4
  • 17
1
vote
1 answer

cancel interval when app goes on background

I new with app and angular. My app use an interval to refresh the scope with a get request to the server. I want that interval to be cancel when the app goes to background. I saw on other post '$onunload=function()' but i'm not sure if it is good or…
Nitrof
  • 121
  • 1
  • 3
  • 15
1 2 3
99
100