Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am looking for a javascript code which will automatically run itself multiple times on a site when i enter it in console . I have already tried and it works only once. Is there any way to automatically run it again and again ?
You can use setInterval function.
Example:
function myFunction(){
console.log('Success!');
}
setInterval(function(){
myFunction();
}, 3000); //you can set the interval here.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Using javascript, is there a way to implement a timer so that the user only has a limited time to complete a payment form after which a warning is displayed / then the browser redirects to the home page?
<script>
var REQIRED_TIME_IN_MS=1000*60*5; //5 minutes
setTimeout(function(){
alert("YOUR_MESSEGE");
window.location.href= "YOUR_HOMEPAGE_LOCATION";
},REQIRED_TIME_IN_MS);
</script>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to execute function in angular on a specific time interval and how can we stop that too. Please give me solution for that.
Your question seems to be about JavaScript in general, not specifically Angular.
You could use setInterval and clearInterval to execute a function on a fixed interval:
// Will print each second
let interval = setInterval(() => console.log("I am a text"), 1000)
// Stops the interval
clearInterval(interval)
Documentation: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am changing my javascript code but browser somehow using old code which i deleted, somehow caching old code. Why is it happening suddenly? And how to prevent it?
Use Ctr+Shift+R for every run.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Im using social-likes plugin to make function "SNS sharing" in my website.
It works well. But it seem to be not update counters after share.(You must reload page to see new counters)
Thanks for helping me.
Have you tried this:
$('#share2').socialLikes({
forceUpdate: true
});
Advanced Configuration Social-Likes
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
So I wish to loop the javascript going to a certain page (without actually reloading/clearing console), then execute
href="javascript:doSomething(9)"
and then loop that by doing a function
Please help, thanks!
Assuming you want it to repeat - you can use an interval.
setInterval(function(){
doSomething(9);
},100); // the 100 is for 100 miliseconds
If you want it to repeat without having to wait (that is, block the code) you can use a normal while loop:
while(true){ // will loop forever since the condition is always "true"
doSomething(9);
}